Background:
I have a problem with a component, which changes the current thread culture to "en-US" every time after a call to a specific method of it. Further in my process that leads to problems, e.g. the data access layer is no more working because SqlParameter's CultureInfo gets also changed to "en-US", thus a given string can't be parsed no more to a DateTime SqlValue.
Possible solution:
So the idea is to backup the threads current culture before and restore it afterwards the call to the specific method which changes the current threads culture. When restoring the culture first i check for the culture if it has changed at all.
The Problem/Question:
I could compare the backuped CultureInfo.Name
with Thread.CurrentThread.CurrentCulture.Name
but I could also use the .Equals()
method of the CultureInfo instance. Which is the better way for comparing two CultureInfo instances? Is there maybe a third/better solution?