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);是格式化字符串的更好选择 –