Tedd Hansen
Tedd Hansen

Reputation: 12316

CultureInfo.Region works in Immediate window, not in code

I tested this on both .Net 4.0 and .Net 4.0 CP, same result.

This line: global::System.Globalization.CultureInfo.GetCultureInfo("en-us").Region

If I type it in Visual Studio (C#), then Visual Studio tells me "Region" isn't valid. If I type the same line in Immediate window during a breakpoint it is fully valid and returns data as expected. And from what I can see "Region" is not in the MSDN documentation.

Obviously two different objects for some reason.
Why? Whats happening here? Why is reality not consistent? I get scared!
(More seriously, I see behaviour I don't understand so I'd like to understand it.)

Immediate window returns:

global::System.Globalization.CultureInfo.GetCultureInfo("en-us").Region
{US}
    CurrencyEnglishName: "US Dollar"
    CurrencyNativeName: "US Dollar"
    CurrencySymbol: "$"
    DisplayName: "United States"
    EnglishName: "United States"
    GeoId: 244
    IsMetric: false
    ISOCurrencySymbol: "USD"
    Name: "US"
    NativeName: "United States"
    ThreeLetterISORegionName: "USA"
    ThreeLetterWindowsRegionName: "USA"
    TwoLetterISORegionName: "US"

While Visual Studio go all red on me: Visual Studio don't recognize CutlureInfo.Region

Upvotes: 2

Views: 900

Answers (2)

Andrea
Andrea

Reputation: 1868

Current RegionInfo is available using

RegionInfo.CurrentRegion

Upvotes: 0

Dmitry Egorenkov
Dmitry Egorenkov

Reputation: 1055

Region is a non-public property of the CultureInfo class. It seems that the immediate window has access to it.

Upvotes: 3

Related Questions