如何用for得到Dictionary内的key和value
展开全部
Dictionary<string, int> userlist = new Dictionary<string, int>();
userlist.Add("qiu", 178);
string[] keys = new string[userlist.Count];
int i = 0;
foreach (string key in userlist.Keys) keys[i++] = key;
for (i = 0; i < keys.Length; i++)
{
Console.WriteLine(userlist[keys[i]]);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询