//字符串转换为字符串数组
string str= "A B C D E F";
//可根据字符串特点,用SPlit方法进行分割
string[] attr= str.Split(' '); //attr={"A","B","C","D","E","F"}
//字符串转换为字节数组
string Msg = "你好123";
byte[] msg = Encoding.Default.GetBytes(Msg);
//字符串数组转换为字节数组
private byte[] byteTostring(string[] strdata)
{
int count = strdata.Length;
byte[] bt = new byte[count];
int j = 0;
foreach (string str in strdata)
{
bt[j] = (byte)Convert.ToInt32(str, 16);
j++;
while (j >= count)
{
break;
}
}
字符串转换为字符串数组和字节数组,字符串数组转换为字节数组
最新推荐文章于 2024-08-07 23:10:12 发布