Dictionary<string, int> list = new Dictionary<string, int>();
list.Add("1", 1);
//
foreach(var item in list)
{
Debug.Log(item.Key + item.Value);
}
//使用KeyValuePair
foreach(KeyValuePair<string,int> item in list)
{
Debug.Log(item.Key + item.Value);
}
//通过键的集合取值
foreach(string key in list.Keys)
{
Debug.Log(key+list[key]);
}
//直接取址
foreach(int val in list.Values)
{
Debug.Log(val);
}
//for
List<string> test = new List<string>(list.Keys);
for(int i = 0; i < list.Count;i++)
{
Debug.Log(test[i] + list[test[i]]);
}

被折叠的 条评论
为什么被折叠?



