Skip to main content
edited tags
Link
svick
  • 246.5k
  • 54
  • 405
  • 535
Source Link
myfunnyfella
  • 1.5k
  • 3
  • 19
  • 25

Parameterless constructors in structs for C# 6

My understanding is that Parameterless constructors in structs are now allowed.

But the following gives me a compile error in VS 2015 Community

public struct Person 
{ 
    public string Name { get; } 
    public int Age { get; } 
    public Person(string name, int age) { Name = name; Age = age; } 
    public Person() : this("Jane Doe", 37) { } 
}

Error: "Structs cannot contain explicit parameterless constructors"

Anyone know why?