作者Ammenze (蓝天白云)
看板C_Sharp
标题Re: [问题] array的封装
时间Wed Jul 22 09:39:55 2015
※ 引述《sweetjp6 (水饺)》之铭言:
: 想请问一个array封装的办法
: Ex:
: private Dictionary<string, string>[] xyz =
: new Dictionary<string, string>[]
: {
: new Dictionary<string, string>(),
: new Dictionary<string, string>(),
: new Dictionary<strgin, string>()
: }
改用 private List<Dictionary<string, string>> xyz =
new List<Dictionary<string, string>>();
xyz.add(new Dictionary<string, string>());
这样直接 xyz[0]就可以取得/更新xyz第一个Dictionary,
不需要下面这段
: public Dictionary<string, string>[] Xyz
: {
: get;
: set;
: }
: 请问get, set部分应该怎麽写才能够access到每个元素呢?
: 可能用法如下:
: Dictionary<string, string> x1 = Xyz[0];
: 请各位不吝赐教, 谢谢
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.34.112.102
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1437529198.A.CCA.html