.net设置键值对代码

public static Dictionary<string, string> ball = new Dictionary<string, string> {   

                                              { "2", "篮球" },  

                                              { "1", "羽毛球" },  

                                              { "19", "桌球" },  

                                              { "57", "高尔夫" },  

                                              { "165", "足球" },  

                 { "22", "游泳" }}; 

//键值对取值  

       foreach(var k in ball.Keys)  

       {  

            if(ball[k].Contains(key))  

           {  

                items.Append("[" + k+ "]" +ball[k]).Append(" ");  

            }       

     }  

 

 

 

原文地址:https://www.cnblogs.com/qhy1277/p/6369782.html