c# - a 有什么作用?在新的 Type?[5] 作业中做什么?

标签 c#

我有以下代码,但我不知道?是什么意味着在构造中。

它在做什么?

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/

相关文章:

c# - algorithm-shorten +10 digits 字符串

c# - GetCommandLineArgs 没有返回我预期的结果

c# - 有没有办法在 ASP.NET Core 3.1 应用程序端点中应用服务器 SSL 证书?

c# - 将 "Treat wchar_t as built-in type"设置为 No 会影响 C# 互操作吗?

c# - 如何使用 mono.cecil 添加没有默认构造函数的自定义属性

c# - 尝试与光线转换命中的对象上的组件进行交互,收到 NullReferenceException

c# - 迭代作业列表以打印职位、姓名、雇主、职位和核心能力

c# - 从枚举中获取值到通用列表中

c# - WinForms DataBinding 是否需要 BindingSource 和 BindingList?

c# - 无法使用我的身份服务器从 native 应用程序调用 API