using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication24{ public struct kong<T> where T : struct { T value; } class Program { static void Main(string[] args) { System.Nullable<int> i1 =new Nullable<int>(); i1 = null; kong<int> bb = new kong<int>(); bb = null;//錯誤 1 無法將 Null 轉(zhuǎn)換成“ConsoleApplication24.kong<int>”,因?yàn)樗且环N不可為 null 值的類型 } }}
2 回答

函數(shù)式編程
TA貢獻(xiàn)1807條經(jīng)驗(yàn) 獲得超9個贊
值類型是不能為空的,可空類型 如:int? 其實(shí)是Nullable<T>
可能fcl中的定義是Nullable<T> 的格式定義的

幕布斯7119047
TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個贊
因?yàn)槟愣x成了struct,struct是不能為null的,如果需要為null,定義成class即可
- 2 回答
- 0 關(guān)注
- 767 瀏覽
添加回答
舉報
0/150
提交
取消