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

后端 未结 10 2003
时光说笑
时光说笑 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:42

    Just special-case it. If you see a numerator of 0 and a denominator of 0, pretend like it has the values you really want.

提交回复
热议问题