Search code examples
c#visual-studiocultureinfo

int.ToString() error on string concatenation Visual Studio 2019


After i updated my Visual Studio 2019 from v16.2.5 to v16.3.5 some errors occured in my application in every place where i use string concatenation.

Ex:

int x = 5;
string y = x + " years";

What has changed? How does the Culture influences int? enter image description here


Solution

  • I think you might have ticked the treat warnings as errors radio button.

    An int can be displayed in western digits (0, 1, 2, 3, ... 9) or it can be displayed in other digits such as Arabic (٠ ١ ٢ ٣) or Thai (๑ ๒ ๓) and so on.

    Therefor, an int representation is culture dependent, and hence the error.

    For more information, check out official documentation.