Convert to char

In this chapter you will learn:

  1. How to convert string to char
  2. Cast integer to a char

Convert string to char

using System;/*ja v a2s .  c o m*/

class MainClass
{
    public static void Main(string[] args)
    {
    char myChar = char.Parse("w");
    Console.WriteLine("-> Value of myChar: {0}\n", myChar);
    }
}

Cast integer to a char

using System;/*  j  ava2s . c o  m*/

class MainClass
{
  static void Main(string[] args)
  {
    char MyChar = 'A';
        MyChar = (char)67;

        Console.WriteLine(MyChar);
  }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. UTF-16 Character
  2. Using Unicode Encoding to Display a Smiley Face
Home » C# Tutorial » bool, char
bool
bool and if statement
bool value to string
Parse string to bool value
char type
char escape sequence
char case
Compare char value
char min/max value
Is char a digit
Is char a letter
Is char a symbol
Is char a Separator
Is char white space
Convert to char
UTF-16 Character