Is there a way to set a DLL to always follow CultureInfo.InvariantCulture by default, if not specifi

Posted by JL on Stack Overflow See other posts from Stack Overflow or by JL
Published on 2010-05-01T09:26:28Z Indexed on 2010/05/01 9:37 UTC
Read the original article Hit count: 168

Filed under:

I have a lot of code in a class library that does not specify CultureInfo.InvariantCulture. For example in toString operations, toBool, toInt, etc.

Is there a way I can get set a property for the class library to always execute using CultureInfo.InvariantCulture, even if it is not explicitly specified everywhere in the code?

Sort of like a global switch?

It is not only messy to have to explicitly type it everytime, it makes my code less readable, and is a royal pain for example:

if (Convert.ToInt16(task.RetryCount, CultureInfo.InvariantCulture) <
            Convert.ToInt16(ConfigurationManager.AppSettings["TasksMaxRetry"], CultureInfo.InvariantCulture))

© Stack Overflow or respective owner

Related posts about c#