How do you get a byte array out of a string in C#? I would like to pass a string to this method.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Encoding.UTF8.GetBytes("abcd");
回答2:
Try
public static byte[] StrToByteArray(string str)
{
System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding();
return encoding.GetBytes(str);
}
回答3:
Use GetBytes( )
回答4:
Encoding.GetBytes
method.