How are 4 bytes characters represented in C#

1.5k views Asked by At

How are 4 bytes chars are represented in C#? Like one char or a set of 2 chars?

var someCharacter = 'x'; //put 4 bytes UTF-16 character
1

There are 1 answers

0
Mark Byers On BEST ANSWER

C# can only store characters from the Basic Multilingual Plane in the char type. For characters outside this plane two chars must be used - called surrogates.

You can also use a string literal such as:

string s = "\U0001D11E";

See UTF-16.