It applies only to methods with IFormatProvider overload.
To deal with this problem, I have two static classes: InvariantText and CulturedText , which work with strings in the invariant culture and the current culture, respectively. For example, I have a Format method in each class. That way, I can do culture-neutralizing and culture- IFormatProvider formatting without having to specify an IFormatProvider every time.
Example:
InvariantText.Format("0x{0:X8}",value); CulturedText.Format("Appending file {0}",file);
InvariantText.Format and CulturedText.Format are simply wrappers of the String.Format method and return strings accordingly.
You can even use this template to transfer other functions that require culture-neutral and culture-specific strings. For example, create two methods: InvariantLog and CulturedLog , which complete the Logger.DebugFormat calls in your question and accept the corresponding IFormatProvider in each case.
source share