共用方式為


CultureInfo Constructor

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Updated: June 2010

Initializes a new instance of the CultureInfo class based on the culture specified by name.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Sub New ( _
    name As String _
)
public CultureInfo(
    string name
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

name is null.

CultureNotFoundException

On Windows systems, name is not a valid culture name.

Remarks

For a list of predefined culture names, see the National Language Support (NLS) API Reference at the Go Global Developer Center.

If name is String.Empty, the constructor creates an instance of the invariant culture; this is equivalent to retrieving the value of the InvariantCulture property.

If name is not a valid culture name, the behavior of this constructor differs by platform. On Windows systems, it throws an CultureNotFoundException. On Macintosh systems, it returns a CultureInfo object that represents the system's default culture.

If name is the name of the current system culture, the CultureInfo object instantiated by this method reflects any customizations that the user may have made to the system's culture information. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the user settings are incompatible with the culture associated with the CultureInfo object (for example, if the selected calendar is not a member of the current culture's OptionalCalendars array), the results of the methods and the values of the properties are undefined.

If the culture identifier associated with the specified culture name does not match the culture identifier of the current Windows culture, this constructor creates a CultureInfo object that uses information for the specified culture that is supplied by the operating system.

Older operating system versions do not always recognize the euro as a particular culture's default currency. In this case, the .NET Framework for Silverlight will reflect this inaccuracy because it is dependent on the operating system for its currency information,

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 For unsupported cultures, the CultureInfo constructor throws a PlatformNotSupportedException exception instead of an ArgumentException exception.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Change History

Date

History

Reason

June 2010

Updated exception information.

Content bug fix.

May 2010

Added information on initializing the invariant culture.

Customer feedback.