An explicit parameterless constructor is not allowed. | Lecture 4 - slide 11 : 29 Program 2 |
/* Right, Wrong */ using System; // Error: // Structs cannot contain explicit parameterless constructors. public struct StructThree{ int a; double b; public StructThree(){ a = 1; b = 2.2; } } // OK: // We can program a constructor with parameters. // The implicit parameterless constructor is still available. public struct StructFour{ int a; double b; public StructFour(int a, double b){ this.a = a; this.b = b; } } |