What is the default value of the nullable type “int?” (including question mark)?

前端 未结 3 2103
悲&欢浪女
悲&欢浪女 2020-11-30 08:16

In C#, what is the default value of a class instance variable of type int??

For example, in the following code, what value will MyNullableInt

3条回答
  •  情话喂你
    2020-11-30 08:48

    var x = default (int?);
    Console.WriteLine("x == {0}", (x == null) ? "null" : x.ToString());
    

提交回复
热议问题