CultureInfoConverter Class
Provides a type converter to convert CultureInfo objects to and from various other representations.
For a list of all members of this type, see CultureInfoConverter Members.
System.Object
System.ComponentModel.TypeConverter
System.ComponentModel.CultureInfoConverter
[Visual Basic] Public Class CultureInfoConverter Inherits TypeConverter [C#] public class CultureInfoConverter : TypeConverter [C++] public __gc class CultureInfoConverter : public TypeConverter [JScript] public class CultureInfoConverter extends TypeConverter
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
This converter can only convert a CultureInfo object to and from a string.
For more information about type converters, see the TypeConverter base class and Implementing a Type Converter.
Note You should never create an instance of CultureInfoConverter. Instead, call the GetConverter method of TypeDescriptor. For more information, see the examples in the TypeConverter base class.
Example
[Visual Basic, C#, C++] The following sample converts a variable of type CultureInfo to a string, and vice versa. First it constructs a CultureInfo variable using the Greek culture (represented by "el') and converts it to the string "Greek". Then it converts the string "Russian" to the CultureInfo representation "ru".
[Visual Basic] ' The sample first constructs a CultureInfo variable using the Greek culture - 'el'. Dim myCulture As New System.Globalization.CultureInfo("el") Dim myCString As String = "Russian" Console.WriteLine(TypeDescriptor.GetConverter(myCulture).ConvertTo(myCulture, GetType(String))) ' The following line will output 'ru' based on the string being converted. Console.WriteLine(TypeDescriptor.GetConverter(myCulture).ConvertFrom(myCString)) [C#] // The sample first constructs a CultureInfo variable using the Greek culture - 'el'. System.Globalization.CultureInfo myCulture= new System.Globalization.CultureInfo("el"); string myCString="Russian"; Console.WriteLine(TypeDescriptor.GetConverter(myCulture).ConvertTo(myCulture, typeof(string))); // The following line will output 'ru' based on the string being converted. Console.WriteLine(TypeDescriptor.GetConverter(myCulture).ConvertFrom(myCString)); [C++] // The sample first constructs a CultureInfo variable using the Greek culture - 'el'. System::Globalization::CultureInfo* myCulture = new System::Globalization::CultureInfo(S"el"); String* myCString = S"Russian"; Console::WriteLine(TypeDescriptor::GetConverter(myCulture)->ConvertTo(myCulture, __typeof(String))); // The following line will output 'ru' based on the string being converted. Console::WriteLine(TypeDescriptor::GetConverter(myCulture)->ConvertFrom(myCString));
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.ComponentModel
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CultureInfoConverter Members | System.ComponentModel Namespace