2
我有下面的代碼,它使用一個像這樣的字符串:字符串連接和@
string str = @"this is very important string ,which uses hardcoded name";
我想改變它有輸入參數的值
public void func (string name)
{
// some code
string str = "this is very important string ,which uses " + name;
}
當我生成的字符串我仍然需要使用「@」我能做什麼?
string str = @("this is very important string ,which uses " + name);
你說的「我仍然需要使用‘@’」是什麼意思?你得到什麼錯誤? – helb
string str = String.Format(「這是非常重要的字符串,它使用{0}」,name);是格式化字符串的更好選擇 –