标签:style blog http color os io for re
参考自百科的这篇文章,相信聪明的你一定能够看懂。
var sb = new StringBuilder(); var dict = new Dictionary<string, string>(); dict.Add("1","a"); dict.Add("2", "b"); dict.Add("3", "c"); dict.Add("4", "d"); dict.Add("5", "e"); foreach (var kv in dict) sb.AppendFormat("{0}={1}&", kv.Key, kv.Value); string str = sb.ToString(); string stt = str.Remove(str.Length-1);
优化后:
var sb = new StringBuilder(); var dict = new Dictionary<string, string> {{"1", "a"}, {"2", "b"}, {"3", "c"}, {"4", "d"}, {"5", "e"}}; foreach (var kv in dict) sb.AppendFormat("{0}={1}&", kv.Key, kv.Value); string str = sb.ToString(); string stt = str.Remove(str.Length-1);
我的c#能力在以看得见的速度增长着,codding之余更多了一份快乐和自信。可是,改变了我的生命中的那座城中的她,去了哪里,我该怎样才能找到她。
标签:style blog http color os io for re
原文地址:http://www.cnblogs.com/defoliate/p/3866717.html