将字符串数组转换为字节数组 [英] Converting a string array to a byte array
本文介绍了将字符串数组转换为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,在任何人尝试将其标记为重复项之前,我不是不是要求将一个字符串添加到字节数组。我想要一个包含类似内容的字符串数组:{ 5, 168, 188, 28, 29, 155}被转换为字节数组。我已经搜索过了,但是只能找到字符串到字节数组的字符串,这是完全不同的。谢谢。
Ok, before anyone attempts to label this as a duplicate, I am not asking for a string to a byte array. I want a string array, containing something similar like this: {"5","168","188","28","29","155"} to be converted to a byte array. I have searched, and was only able to find string to byte array, which is quite different. Thanks.
编辑:将预先设置数组,以便每个成员都可以通过byte.Parse进行解析,所以这不是问题。
the array will be preset so that each member is parsable through byte.Parse, so this is not an issue.
推荐答案
对于 无法通过 byte.Parse $ c $解析的任何内容,此操作将失败。 c>
var str = new[] {"5", "168", "188", "28", "29", "155"};
var byt = str.Select(byte.Parse).ToArray();
这篇关于将字符串数组转换为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文