2011-09-26 105 views

回答

10

string.Format將是你選擇的功能的解決方案。

然後,您可以寫例如: -

const string t = "Thomas"; 
var s = string.Format("Good morning {0}.", t); 

隨着{0}t值被替換。

+1

感謝您的快速響應Uwe。 我很感謝你.. –

+3

我在前面的例子中添加了如果你需要幾個格式字符(如printf(「%d%s%d%s」,a,b,c,d)),你必須使用數字括號中的參數:string.Format(「Good morning {0}。{2},{1}」,t,「ru?」,「How」); – Vasya

+1

謝謝,它就像c。 –

相關問題