asp.net 键值对取值

来源:互联网 发布:手机日志软件 编辑:程序博客网 时间:2024/05/12 23:18
 //声明键值对public static Dictionary<string, string> ball = new Dictionary<string, string> {                                                { "2", "篮球" },                                               { "1", "羽毛球" },                                               { "19", "桌球" },                                               { "57", "高尔夫" },                                               { "165", "足球" },                                               { "22", "游泳" }};        string key = context.Request.QueryString["q"].Trim();         StringBuilder items = new StringBuilder();        //键值对取值        foreach(var k in ball.Keys)        {            if(ball[k].Contains(key))            {                items.Append("[" + k+ "]" +ball[k]).Append("\n");            }             }               context.Response.Write(items.ToString()); 


 

原创粉丝点击