日期:2014-05-18 浏览次数:21202 次
string a = "123"; string b = "234"; string c = string.Format("{0},{1}", a, b);
------解决方案--------------------
string str="";//要替换的字符串 Dictionary<string, string> data = new Dictionary<string, string>(); //然后以参数名作为key,参数值作为value添加进去后 foreach(string key in data.Keys) { str=str.Replace("{"+key+"}",data[key]); }
------解决方案--------------------
可以用循环哦。
------解决方案--------------------
string[] value = { "123", "234", "ttt" }; string str = "aaa{参数}bbb{参数}{参数}"; string[] strCollection = Regex.Split(str, @"\{[^}]+\}"); string result = string.Empty; for (var i = 0; i < value.Length; i++) { result += (i > strCollection.Length ? "" : strCollection[i]) + value[i]; } Console.WriteLine(result);