Search code examples
c#refactoringresharper

Any way to not have to include CultureInfo.InvariantCulture in every ToString call?


ReSharper always gets mad at me if I don't specify CultureInfo.InvariantCulture or some other culture in each of my ToString calls. The application is currently only in English but looking towards the future is always good. Is there any way to specify an application setting so all ToString calls by default use InvariantCulture?


Solution

  • One simple way... create an extension method

    public static string MyToString(this int x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }
    

    Give it a better name though :)