我对编程很陌生,我想知道int?
int
会导致什么样的性能损失?我有一个巨大的3维int?
数组,有时我必须投入大量int
。我会受到很大的打击吗?
答案 0 :(得分:0)
在Eric Lippert的以this one开头的Nullable类型的博客系列中找到答案。
在那里他将Nullable结构描绘为
struct Nullable<T> where T : struct
{
...
public T Value
{
get
{
if (!this.HasValue) throw something;
return this.value;
}
}
public T GetValueOrDefault()
{
return this.value;
}
...
}
所以它只是添加了if (bool)
。