convert int to nullable int?

前端 未结 6 789
北恋
北恋 2020-12-15 04:43

I need to know how to convert an int to a nullable int. However, I keep getting an error \"The binary operator Equal is not defined for the types \'System.Nullable`1[System.

6条回答
  •  悲&欢浪女
    2020-12-15 05:19

    int test = 0; // set int
    
    int? num = test; // convert test to a nullable int
    
    num = null; // set num as null
    

提交回复
热议问题