简体   繁体   English

私人int? _City_Id;任何人都可以告诉我“?”在这里意味着什么

[英]private int? _City_Id; can any one tell me what “?” means here

private int? 私人int? _City_Id; _City_Id;

Without knowing your target language to respond with, in C# 2.0 the ? 在不知道你的目标语言回应的情况下,在C#2.0? denotes nullable value types. 表示可空值的类型。

Nullable value types (denoted by a question mark, eg int? i = null;) which add null to the set of allowed values for any value type. 可空值的类型(用问号表示,例如int?i = null;),它将null添加到任何值类型的允许值集合中。

Which, as Calum points out ( all credit to him ), means that the variable can be assigned null . 正如Calum指出的那样( 对他而言都是信用 ),意味着可以将变量赋值为null Normally primitives like int and double can't be null, 通常像intdouble这样的原语不能为null,

int? x = 10;
double? d = 4.108

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM