I have a UTF-8 string and ...
No no. It's impossible. You may have a byte sequence (array or stream) that contains UTF-8 encoded text. But not string .
A.net string always contains Unicode (or, more precisely, UTF-16).
... so how can I convert my string to a UTF-16 byte array?
string myText = ...;
The library defines the range of UTF7 , UTF8 , Unicode , UTF32 . Unicode is UTF16 in the context of the .NET platform.
source share