Will the code compile?
struct MyStructure3 { MyStructure3() { } }
No. We cannot use the explicit parameterless constructor here.
Can a structure contain properties?
struct MyStructure3 { private int myInt; public int MyInt { get { return myInt; } set { myInt = value; } } }
Yes.
Can we create a structure like this?
struct S
{
protected int i;
}
No. structs can implement an interface but they cannot inherit from another struct. For that reason, struct members cannot be declared as protected.
Will the code compile?
using System; struct OuterStruct { public void Show() { Console.WriteLine("I am in OuterStruct"); } // internal struct InnerStruct protected struct InnerStruct { public void Show() { Console.WriteLine("I am in InnerStruct"); } } }
No. protected or protected internal is not allowed here.