#24 – Character Literals

There are several different ways of specifying single character literals in C#.  Each character is a 2-byte Unicode character and is of type char.

Here are some examples of character literals:

char c1 = 'A';
char c2 = '^';
char c3 = '\'';    // Escape: single quote
char c4 = '\\';    // Escape: backslash
char c5 = '\x45';  // Hex code for ASCII 'E'
char c6 = '\x20AC';  // Hex code for Euro sign
char c7 = '€';     // Euro sign directly in code

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #24 – Character Literals

  1. Pingback: #477 – Full List of Escape Sequences for Character Literals « 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: