Reputation: 7673
A bit of a dumb one... but how do I get a variable of type char to have a value of '
?
e. g.
char c = ''';
char a = 'A';
char b = 'B';
Upvotes: 4
Views: 200
Reputation: 14810
char a=65 means 'A' in c++. don't know whether it will work in c#
To complete you answer: in C#, the following statement won't compile, because you're trying to put an Int32 into a Char (no implicit casting exists)
char a = 65;
To convert ASCII codes to a character, you have to use the static Convert class in C#:
char a = Convert.ToChar(65); // where 65 is the ascii
Upvotes: 2
Reputation: 18170
char c = '\'';
the backslash is called an escape character.
and if you want a backslash it's
char c = '\\';
Here's some more for good measure:
Upvotes: 12