C#设定有序集合列表

建立有序集合列表: 

var categorykey = new SortedList<string, string>();

    categorykey.Add("BZ", "业务");
    categorykey.Add("MR", "管理");

    categorykey.Add("TT", "测试");

遍历有序集合列表:

 foreach (KeyValuePair<string, string> obj in categorykey)

    {

Console.WriteLine("Key:"+obj.Key.ToString()+" Value:"+obj.Value.ToString());

}

遍历有序集合Key:

foreach(string str in categorykey.Key)

{

    Console.WriteLine(str);

}

遍历有序集合Value:

foreach(string str in categorykey.Value)

{

    Console.WriteLine(str);

}


猜你喜欢

转载自blog.csdn.net/touhousonic/article/details/79923358
今日推荐