char

suggest change

A char is single letter stored inside a variable. It is built-in value type which takes two bytes of memory space. It represents System.Char data type found in mscorlib.dll which is implicitly referenced by every C# project when you create them.

There are multiple ways to do this.

  1. char c = 'c';
  2. char c = '\u0063'; //Unicode
  3. char c = '\x0063'; //Hex
  4. char c = (char)99;//Integral

A char can be implicitly converted to ushort, int, uint, long, ulong, float, double, or decimal and it will return the integer value of that char.

ushort u = c;

returns 99 etc.

However, there are no implicit conversions from other types to char. Instead you must cast them.

ushort u = 99;
char c = (char)u;

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents