int.ToString() 字符串连接错误 Visual Studio 2019
int.ToString() error on string concatenation Visual Studio 2019
在我将 Visual Studio 2019 从 v16.2.5 更新到 v16.3.5 后,我的应用程序在我使用字符串连接的每个地方都出现了一些错误。
例如:
int x = 5;
string y = x + " years";
发生了什么变化?文化如何影响智力?
此消息源于 Visual Studio 的代码分析功能。有关此特定警告的更多信息,请参阅 the documentation。上面写着:
[...] .NET members choose default culture and formatting based on
assumptions that might not be correct for your code. To make sure that
the code works as expected for your scenarios, you should supply
culture-specific information according to the following guidelines: [...]
注意 .ToString
最终显示给用户的调用通常是一种很好的做法。
我想您可能已经勾选了 treat warnings as errors
单选按钮。
int 可以用西方数字(0、1、2、3、... 9)显示,也可以用其他数字显示,例如阿拉伯语 (٠ ١ ٢ ٣) 或泰语 (๑ ๒ ๓) ) 等等。
因此,int 表示依赖于文化,因此会出现错误。
有关详细信息,请查看 official documentation.
在我将 Visual Studio 2019 从 v16.2.5 更新到 v16.3.5 后,我的应用程序在我使用字符串连接的每个地方都出现了一些错误。
例如:
int x = 5;
string y = x + " years";
发生了什么变化?文化如何影响智力?
此消息源于 Visual Studio 的代码分析功能。有关此特定警告的更多信息,请参阅 the documentation。上面写着:
[...] .NET members choose default culture and formatting based on assumptions that might not be correct for your code. To make sure that the code works as expected for your scenarios, you should supply culture-specific information according to the following guidelines: [...]
注意 .ToString
最终显示给用户的调用通常是一种很好的做法。
我想您可能已经勾选了 treat warnings as errors
单选按钮。
int 可以用西方数字(0、1、2、3、... 9)显示,也可以用其他数字显示,例如阿拉伯语 (٠ ١ ٢ ٣) 或泰语 (๑ ๒ ๓) ) 等等。
因此,int 表示依赖于文化,因此会出现错误。
有关详细信息,请查看 official documentation.