日期:2014-05-17 浏览次数:21118 次
string s = "data source=127.0.0.1;uid=sa;pwd=sa;database=pub;"; Dictionary<string, string> dictionary = s.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToDictionary(x => x.Split('=')[0], x => x.Split('=')[1]); foreach (KeyValuePair<string, string> pair in dictionary) Console.WriteLine(pair.Key + ":" + pair.Value); Console.WriteLine("uid的值是:" + dictionary["uid"]);