Convert.ToChar Method in C#


The Convert.ToChar method is used to convert a specified value to a Unicode integer.

We have declared an sbyte variable.

sbyte byteVal = 200;

Now, use the Convert.ToChar() method to convert the sbyte value to a Unicode integer.

charVal = Convert.ToChar(b);

Let us see another example.

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      sbyte[] byteVal = { 92, 111, 115 };
      char charVal;
      foreach (sbyte b in byteVal) {
         charVal = Convert.ToChar(b);
         Console.WriteLine("{0} converted to '{1}'", b, charVal);
      }
   }
}

Output

92 converted to '\'
111 converted to 'o'
115 converted to 's'

Updated on: 23-Jun-2020

823 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements