What's the difference between 'int?' and 'int' in C#?

后端 未结 7 1174
甜味超标
甜味超标 2020-12-02 17:44

I am 90% sure I saw this answer on stackoverflow before, in fact I had never seen the \"int?\" syntax before seeing it here, but no matter how I search I can\'t find the pre

7条回答
  •  感动是毒
    2020-12-02 18:38

    the symbol ? after the int means that it can be nullable.

    The ? symbol is usually used in situations whereby the variable can accept a null or an integer or alternatively, return an integer or null.

    Hope the context of usage helps. In this way you are not restricted to solely dealing with integers.

提交回复
热议问题