以下はなぜ禁止されているのですか?
Nullable<Nullable<int>>
一方
struct MyNullable <T>
{
}
MyNullable<Nullable<int>>
ではありません
sでは、null 非許容値型のみを使用できると思いますNullable
。それNullable
自体は null 許容であるため、この方法でのネストは禁止されています。
http://msdn.microsoft.com/en-us/library/kwxxazwb.aspxから
public Nullable( T value )
タイプ: TA 値タイプ。
CLRに組み込まれているNullable型のボックス化とアンボックス化が明示的にサポートされているため、Nullableは特別です。
に対してMSILbox
命令を使用すると、結果としてNullable<T>
実際にが得られます。null
ボックス化されたときにnullを生成する他の値型はありません。
開梱には、同様の対称的なサポートがあります。
The generic type parameter for Nullable must itself be a non-nullable type (i.e. value type). This is the C# compiler warning I get, and it would seem to make sense. Tell me, why would you want to do such a thing anyway? I personally can see no use, and little meaning to such a declaration even.