Why can't I define a default constructor for a struct in .NET?

后端 未结 10 2090
时光说笑
时光说笑 2020-11-22 11:04

In .NET, a value type (C# struct) can\'t have a constructor with no parameters. According to this post this is mandated by the CLI specification. What happens i

10条回答
  •  轮回少年
    2020-11-22 11:36

    You can't define a default constructor because you are using C#.

    Structs can have default constructors in .NET, though I don't know of any specific language that supports it.

提交回复
热议问题