Why does C# 3 allow the implicit conversion of literal zero (0) to any Enum?

前端 未结 5 613
后悔当初
后悔当初 2020-12-06 18:12

C#3 (Visual Studio 2008) introduced a breaking change to the language (http://msdn.microsoft.com/en-us/library/cc713578.aspx, see change 12) that allows any literal zero to

5条回答
  •  孤城傲影
    2020-12-06 18:31

    "The default underlying type of the enumeration elements is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1." - This is from MSDN notes for 1.1 framework, so it's always been the case.

提交回复
热议问题