What is the difference between char and char?

Possible duplicate:
What is the difference between row and row

When I run:

char c1 = 'a'; Console.WriteLine(c1); 

and at startup:

 Char c2 = 'a'; Console.WriteLine(c2); 

I get exactly the same result, a .

I wanted to know what is the difference between the two forms and why there are two forms?

+7
source share
3 answers

The result is exactly the same. Both are of the same type, so the resulting executable files are completely identical.

The char keyword is a C # alias for the type System.Char in the framework.

You can always use the char keyword. To use char , you need using System; include the System namespace at the top of the file (or use System.Char to specify the namespace).


In most situations, you can use either a keyword or a frame type, but not everywhere. For example, as a type of support in an enumeration, you can use only the keyword:

 enum Test : int { } // works enum Test : Int32 {} // doesn't work 

(I use int in the example, since you cannot use char as the support type for an enumeration.)


Related: Difference between bytes and byte data types in C #

+8
source

As far as I know, a keyword like C # char is just an alias for System.Char , so they are of the same type.

+5
source

The char keyword is an alias of type System.Char in C #.

+1
source

All Articles