user1650004
user1650004

Reputation: 131

Unicode string in C#

I remember using Unicode string in C++ such as this:

std::wstring str = _T("a string here");

What is the equivalent in C#?

Upvotes: 2

Views: 20014

Answers (2)

skjcyber
skjcyber

Reputation: 5957

Use System.Text.UnicodeEncoding class. This handles UTF-16 encoding of Unicode characters.

Upvotes: 0

Cristian Lupascu
Cristian Lupascu

Reputation: 40506

The equivalent in C# is the String class.

According to MSDN:

(A String) Represents text as a series of Unicode characters.

[...] Each code point is encoded using UTF-16 encoding

So, if you do string str = "a string here";, you have a Unicode string.

Upvotes: 9

Related Questions