我有我需要转换为.NET字节数组相当于一个字符串。
I have a string that I need to convert to the equivalent array of bytes in .NET.
这应该是容易的,但我有脑抽筋。
This ought to be easy, but I am having a brain cramp.
您需要使用的编码告诉.NET你所期望的输出。例如,使用UTF-16:
You need to use an encoding to tell .NET what you expect as the output. For example, in UTF-16:
var result = System.Text.Encoding.Unicode.GetBytes(text);