當前位置:成語大全網 - 新華字典 - c#字典怎麽獲取第壹個鍵值

c#字典怎麽獲取第壹個鍵值

Dictionary<string,?int>?dictionary?=?new?Dictionary<string,?int>();

dictionary.Add("A1",?123);

dictionary.Add("A2",?456);

KeyValuePair<string,int>?kvp=dictionary.FirstOrDefault();//?獲取第壹個

Console.WriteLine("Key={0}\tValue={1}",kvp.Key,kvp.Value);