2011-09-26 20 views
-4

我有這樣的事情我有一種在碼評價問題

"This" + " " + "is" + " " + "the" + " " + row["Message"].ToString() + " " + "test" + " " + "sms" + " " + "to" + " " + row["Name"].ToString(); 

它在建造時的代碼執行

+2

好了..現在問題是什麼 ? – V4Vendetta

+0

我的問題是爲什麼你有這樣的事情? –

回答

2

不能確定你的問題是什麼,但我會建議你使用字符串。格式?

var message = string.Format("This is the {0} test sms to {1}", row["Message"], row["Name"]); 
0

這是一個可怕的字符串連接的做法,不容易閱讀和亂七八糟的理解和維護,我建議你用這樣的使用方法string.Format替換:

var result = String.Format("This is the '{0}' test sms to '{1}'", 
row["Message"].ToString(), row["Name"].ToString());