Table of contents >> Introduction > Char variable type
High importance article

C# language uses char variable type to store values of type character. The C# compiler allocates 16 bits (2 bytes) to store a char variable, which is similar to the ushort type. The char variable type can store integer value types ranging from 0 to 65535. The following image shows the representation of such a variable.

You can assign values to char variables like this:

1
char letter = 'A';

The second way of assigning a value to a char variable is casting an int type into a char type (converting one variable type into another variable type).

1
char c = Convert.ToChar(65); // ASCII value 65 equals to character A

char variable type can only store one letter at a time. To store more characters, you have to declare a string, which we will explain later.

The concepts explained in this lesson are also shown visually as part of the following video: