Type Summary

Type Summary

public class CultureInfo : ICloneable, IFormatProvider


    // Constructors

    MS public CultureInfo(int culture);

    MS public CultureInfo(int culture, bool useUserOverride);

    MS public CultureInfo(string name);

    MS public CultureInfo(string name, bool useUserOverride);

    // Properties

    MS public virtual Calendar Calendar { get; }

    MS public virtual CompareInfo CompareInfo { get; }

    MS public static CultureInfo CurrentCulture { get; }

    MS public static CultureInfo CurrentUICulture { get; }

    MS public virtual DateTimeFormatInfo DateTimeFormat { get; set; }

 MS CF public virtual string DisplayName { get; }

    MS public virtual string EnglishName { get; }

 MS CF public static CultureInfo InstalledUICulture { get; }

    MS public static CultureInfo InvariantCulture { get; }

    MS public virtual bool IsNeutralCulture { get; }

    MS public bool IsReadOnly { get; }

    MS public virtual int LCID { get; }

    MS public virtual string Name { get; }

    MS public virtual string NativeName { get; }

    MS public virtual NumberFormatInfo NumberFormat { get; set; }

    MS public virtual Calendar[] OptionalCalendars { get; }

    MS public virtual CultureInfo Parent { get; }

    MS public virtual TextInfo TextInfo { get; }

    MS public virtual string ThreeLetterISOLanguageName { get; }

    MS public virtual string ThreeLetterWindowsLanguageName { get; }

    MS public virtual string TwoLetterISOLanguageName { get; }

    MS public bool UseUserOverride { get; }

    // Methods

 MS CF public void ClearCachedData();

    MS public virtual object Clone();

    MS public static CultureInfo CreateSpecificCulture(string name);

    MS public override bool Equals(object value);

 MS CF public static CultureInfo[] GetCultures(CultureTypes types);

    MS public virtual object GetFormat(Type formatType);

    MS public override int GetHashCode();

    MS public static CultureInfo ReadOnly(CultureInfo ci);

    MS public override string ToString();


SS For the CultureInfo constructor overloads you really want to use names instead of the int/LCID. Names allow you to access custom cultures that a user may install for future versions, and will be more extensible in the future. You also really want to use user overrides. User overrides are there because the user did not like the defaults, or because they are inappropriate or ambiguous for the user's environment.

SS Always use cultures when appropriate, but be careful where you use them. They are meant to be specific for a user or machine, and they could change. For example, as countries join the EU, their currency symbols or formats change. In other cases, companies or users may prefer a 24-hour clock to a 12-hour default. Culture data is necessary and great when presenting data to the humans who are actually using the computer, but it's an awful way to store data. If you have to read something back later, save it in a binary format, use CultureInfo.InvariantCulture, or specify a specific format to the formatting functions. Except for Invariant, don't expect the culture data provided by this class to remain the same, even between instances running as the same user.

BG CultureInfo is a useful encapsulation of all the culture-specific data that you'll need for your operations. It can be used to control string comparisons, number formatting, date and calendar formatting, and resource lookups. See Thread's CurrentCulture and CurrentUICulture for ways of setting this culture on your current thread. It is also one of the most interesting types that implement IFormatProvider. The ToString method on our numeric types and DateTime will call GetFormat(typeof(NumberFormatInfo)) or GetFormat(typeof (DateTimeFormatInfo)) for formatting and parsing.

BG We were never quite sure we got the balance between this type and RegionInfo correct. RegionInfo is very commonly overlooked, when you'd expect that perhaps some of the features on this class would be on RegionInfo instead.

BG In future versions of the Common Language Runtime, look for custom culture support and custom resource fallback support. Custom culture support will allow users to define their own cultures in an easy manner that the entire system will respect.

For the System.Resources.ResourceManager, we hope to eventually add in support for fallback along more axes beyond culture, like age (for different scripts like Hiragana or Katakana), gender, and perhaps region or ZIP code (e.g., for different phone numbers).

IA One of my biggest regrets is that CultureInfo.ClearCachedData() is an instance method rather than a static method. This method actually clears shared (static) caches for system settings like CurrentCulture, CurrentRegion, and the like. It does nothing to individual instances, so it is very confusing to have this as an instance method. Unfortunately, this was discovered very late in the .NET Framework cycle, and it was considered a breaking change to make it static, so it had to ship this way.

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows