我目前正在更新一些工作中的旧代码。我遇到了很多行,其中似乎毫无理由地使用了string.Format()。我想知道是否在没有其他参数的情况下使用string.Format()有一些用处,但我想不出任何用处。
这有什么区别:
string query = String.Format(@"select type_cd, type_shpmt from codes");
Run Code Online (Sandbox Code Playgroud)
和这个:
string query = "select type_cd, type_shpmt from codes";
Run Code Online (Sandbox Code Playgroud)
我也认为@不需要,因为它不需要是字符串文字,并且它不是多行字符串。