Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CharConverter Class

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

For a list of all members of this type, see CharConverter Members.


[Visual Basic]
Public Class CharConverter
   Inherits TypeConverter
public class CharConverter : TypeConverter
public __gc class CharConverter : public TypeConverter
public class CharConverter 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.


This converter can only convert a string, with a length of one, to and from a character.

For more information about type converters, see the TypeConverter base class and Implementing a Type Converter.

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


[Visual Basic, C#, C++] The following example converts a variable of type Char to a string variable, and vice versa.

[Visual Basic] 
Dim chrA As [Char] = "a"c
Dim strB As String = "b"
Console.WriteLine(TypeDescriptor.GetConverter(chrA).ConvertTo(chrA, GetType(String)))

Char chrA='a';
string strB="b";
Console.WriteLine(TypeDescriptor.GetConverter(chrA).ConvertTo(chrA, typeof(string)));

char chrA( 'a' );
String* strB = S"b";
Console::WriteLine(TypeDescriptor::GetConverter(__box(chrA))->ConvertTo(__box(chrA), __typeof(String)));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


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

CharConverter Members | System.ComponentModel Namespace

© 2018 Microsoft