我有以下代码,但我不知道?
是什么意味着在构造中。
它在做什么?
myObj_Request r = new myObj_Request(); //instantiate intial object
r.Channels = new ChannelSequence(); //initial object has another object in channels
r.Channels.ChannelType = new ChannelType?[5] { .. } // ok so we have 5 channeltypes...
// but that ? infront of [5] ?
最佳答案
它是一个可为空的类型。区别?
int c = 5; // you can set only numbers
int? d = null; // you can set int or null
int? e = 5;
int?
基本上 完全等于 Nullable<int>
.
这是引用:MSDN
[编辑]
所以new ChannelType?[5]
是 Nullable<ChannelType>
的数组(5 个元素) .
关于c# - a 有什么作用?在新的 Type?[5] 作业中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17744222/