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.
You need to use an encoding (System.Text.Encoding
) to tell .NET what you expect as the output. For example, in UTF-16 (= System.Text.Encoding.Unicode
):
var result = System.Text.Encoding.Unicode.GetBytes(text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With