国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#中怎么將一個List轉換為只讀的

2020-01-24 03:11:14
字體:
來源:轉載
供稿:網友
如題,主要使用AsReadOnly這個方法就可以了
復制代碼 代碼如下:

List<int> a = new List<int> {1, 2, 3, 4, 5}; 

IList<int> b = a.AsReadOnly(); // block modification... 

IList<int> c = b.AsWritable(); // ... but unblock it again 

c.Add(6); 
Debug.Assert(a.Count == 6); // we've modified the original 

IEnumerable<int> d = a.Select(x => x); // okay, try this... 

IList<int> e = d.AsWritable(); // no, can still get round it 

e.Add(7);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台东县| 襄城县| 凯里市| 新沂市| 房产| 和平县| 固始县| 北票市| 修武县| 商南县| 郧西县| 长寿区| 崇左市| 威远县| 阳东县| 神池县| 陇南市| 宁陵县| 涞水县| 平塘县| 和龙市| 手游| 江陵县| 遵义县| 介休市| 新乡县| 晴隆县| 白银市| 阿坝| 柳江县| 新兴县| 宣城市| 镶黄旗| 刚察县| 兴山县| 通江县| 兴隆县| 睢宁县| 托克托县| 修水县| 陕西省|