Can CultureInfo.CurrentCulture ever be null?

.net, cultureinfo

Solution

It definitely looks like it's guaranteed to be non-`null`:

The culture is a property of the executing thread. This read-only property is equivalent to retrieving the `CultureInfo` object returned by the `Thread.CurrentCulture` property.

`Thread.CurrentCulture` throws an exception if you try to set it to `null`, so it's logical to assume that having a non-`null` value is an invariant.

Apart from this, `CultureInfo.CurrentCulture` gives the algorithm that determines its initial value:

How a Thread's Culture Is Determined

When a thread is started, its culture is initially determined as follows:

By retrieving the culture that is specified by the `DefaultThreadCurrentCulture` property in the application domain in which the thread is executing, if the property value is not `null`.

By calling the Windows `GetUserDefaultLocaleName` function.

Again, this doesn't leave open the option of a `null` value.

Problem

Can CultureInfo.CurrentCulture ever be null? A null value would crash my program, which I don't want. So I'm asking, to be safe, do I need to do? ``` var culture = CultureInfo.CurrentCulture ?? CultureInfo.InvariantCulture ```

Original source