【发布时间】:2014-07-07 21:33:53
【问题描述】:
写下面两个有区别吗?代码用于 C#
String S1 = "The " + Item.Name + " is made of " + Item.Property + " and is at " + Item.Durability + "% durability."
反对
String S2 = "The {0} is made of {1} and is at {2} % durability.", Item.Name, Item.Property, Item.Durability
?假设该项目以字符串形式填充,例如,Axe 的名称、Steel 的属性和 50 的耐久度。
【问题讨论】:
-
我认为那里应该有一个
string.Format。