冰楓論壇
標題:
[C#] Dictionary 取值與賦值操作
[打印本頁]
作者:
whitefox
時間:
2023-6-9 10:48
標題:
[C#] Dictionary 取值與賦值操作
取出Key - 依排序索引
dict.Keys.ElementAt(i);
複製代碼
以下兩種方法都可以取Value
object objValue = dict.Values.ElementAt(i);
複製代碼
object objValue = dict[key];
複製代碼
擴展以上方法取Value
object objValue = dict[dict.Keys.ElementAt(i)];
複製代碼
賦值方法則有這兩種
string sValue = "A";
dict[key] = sValue;
複製代碼
string sValue = "A";
dict[dict.Keys.ElementAt(i)] = sValue;
複製代碼
歡迎光臨 冰楓論壇 (https://bingfong.com/)
Powered by 冰楓