CultureInfoConverter Class

Definition

Provides a type converter to convert CultureInfo objects to and from various other representations.

public class CultureInfoConverter : System.ComponentModel.TypeConverter
Inheritance
CultureInfoConverter

Inherited Members

System.ComponentModel.TypeConverter

System.Object

Examples

The following code example 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".

// The sample first constructs a CultureInfo variable using the Greek culture - 'el'.
System::Globalization::CultureInfo^ myCulture = gcnew System::Globalization::CultureInfo( "el" );
String^ myCString = "Russian";
Console::WriteLine( TypeDescriptor::GetConverter( myCulture )->ConvertTo( myCulture, String::typeid ) );
// The following line will output 'ru' based on the string being converted.
Console::WriteLine( TypeDescriptor::GetConverter( myCulture )->ConvertFrom( myCString ) );
// 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));
' 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))

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 How to: Implement a Type Converter.

Note

You should never create an instance of the CultureInfoConverter class. Instead, call the GetConverter method of the TypeDescriptor class. For more information, see the examples in the TypeConverter base class.

Constructors

CultureInfoConverter()

Initializes a new instance of the CultureInfoConverter class.

Methods

CanConvertFrom(ITypeDescriptorContext, Type)

Gets a value indicating whether this converter can convert an object in the given source type to a CultureInfo using the specified context.

CanConvertTo(ITypeDescriptorContext, Type)

Gets a value indicating whether this converter can convert an object to the given destination type using the context.

ConvertFrom(ITypeDescriptorContext, CultureInfo, Object)

Converts the specified value object to a CultureInfo.

ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)

Converts the given value object to the specified destination type.

GetCultureName(CultureInfo)

Retrieves the name of the specified culture.

GetStandardValues(ITypeDescriptorContext)

Gets a collection of standard values for a CultureInfo object using the specified context.

GetStandardValuesExclusive(ITypeDescriptorContext)

Gets a value indicating whether the list of standard values returned from GetStandardValues(ITypeDescriptorContext) is an exhaustive list.

GetStandardValuesSupported(ITypeDescriptorContext)

Gets a value indicating whether this object supports a standard set of values that can be picked from a list using the specified context.