using System; public class ToStringSample { public static void Main() { char ch = 'a'; Console.WriteLine(ch.ToString()); // Output: a Console.WriteLine(Char.ToString('b')); // Output: b } }.
https://msdn.microsoft.com/en-us/library/3d315df2(v=vs.110).aspx
[Visual Basic] Overloads Public Shared Function ToChar( _ ByVal value As Object _ ) As Char [C#] public static char ToChar( object value ); [C++] public: static __wchar_t ToChar( Object* value ); [JScript] public static function ToChar( value : Object ) : Char;
https://msdn.microsoft.com/en-us/library/aa325081(v=vs.71).aspx
A String of length 1 or a null reference (Nothing in Visual Basic). The Unicode character equivalent to the first and only character in value. value must be a null reference (Nothing in Visual Basic) or a String containing a single character. The following code sample illustrates the use of ToByte, by attempting to convert a String value to a Char: [Visual Basic] Public Sub ConvertStringChar(ByVal stringVal As String) Dim charVal As Char = ac ' A string must be one character long to convert to char.
https://msdn.microsoft.com/en-us/library/aa325084(v=vs.71).aspx
stringVal = System::Convert::ToString(charVal); System::Console::WriteLine(SThe character as a String* is {0}, stringVal); }. [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.
https://msdn.microsoft.com/en-us/library/aa325084(v=vs.71).aspx
C# Corner. Convert string to char array in C#. How to convert a string to a char array using C#. The ToCharArray method of the string class converts a string to a character array. The following code snippet creates a string into a char array.
http://www.c-sharpcorner.com/UploadFile/mahesh/convert-string-to-char-array-in-C-Sharp/
The return value is the result of invoking the IConvertible.ToChar method of the underlying type of value. [Visual Basic, C#, C++] The following code sample illustrates the use of ToByte, by attempting to convert a String value to a Char:
https://msdn.microsoft.com/en-us/library/aa325081(v=vs.71).aspx
This method copies each character (that is, each Char object) in a string to a character array. The first character copied is at index zero of the returned character array; the last character copied is at index Array.Length – 1. To create a string from the characters in a character array, call the String(Char[]) constructor. To create a byte array that contains the encoded characters in a string, instantiate the appropriate Encoding object and call its Encoding.GetBytes(String) method.
https://msdn.microsoft.com/en-us/library/ezftk57x(v=vs.110).aspx
[Visual Basic] Overloads Public Shared Function ToChar( _ ByVal value As String _ ) As Char [C#] public static char ToChar( string value ); [C++] public: static __wchar_t ToChar( String* value ); [JScript] public static function ToChar( value : String ) : Char;
https://msdn.microsoft.com/en-us/library/aa325084(v=vs.71).aspx
The following example calls the ToCharArray method to extract the characters in a string to a character array. It then displays the original string and the elements in the array.
https://msdn.microsoft.com/en-us/library/ezftk57x(v=vs.110).aspx
Alternatively you can do: char myChar = 'X'; string myString = new string(myChar,1); or. string myString = myChar.ToString() and. char myChar = myString[0]; (If you convert a string to a char, you have to choose one of its characters to convert, via array indexing.
https://social.msdn.microsoft.com/Forums/en-US/908be5b5-98a5-44df-94e5-5708270d36d4/how-to-convert-string-to-char-or-vice-versa?forum=csharplanguage
convert a string to char c#
In c#, to convert a string to char: MyString is equals to myChar.