static void Main(string[] args)
{
//初始化
string str = "{0,128,54,56,22,33}";
string[] strs = str.Substring(1,str.Length-2).Split(new char[] { ',' });
byte[] strByte =new byte[strs.Length];
//逐个转换成byte并存入strByte数组
for(int i = 0; i < strs.Length; i++)
{
strByte[i] =Convert.ToByte( strs[i]);
}
//输出strByte[]
for(int i = 0; i < strs.Length; i++)
{
Console.WriteLine(strByte[i]);
}
Console.ReadKey();
}
先字符串拆分,得到string[]{'0','128'..}
然后转类型得到int[] {0,128....}
再转类型 byte b = (byte)