I have the following structure:
I need to create a char array with informational values, I mean, I need something like this:
char[] result = new char[]{Information, Information, Information, Information}
What is the best way to do this? I do this by receiving bytes, then transferring them to bitmaps, then creating a string with informational positions and finally applying the ToCharArray () method to the string with the required information, but I want to know if there is a better way to do this.
var oneByteInfo = message.ReadBytes(1);
var oneByteInfo2 = message.ReadBytes(1);
var infoBitArray = new BitArray(oneByteInfo);
var info2BitArray = new BitArray(oneByteInfo2);
var arrayString = Convert.ToString(BitConverter.GetBytes(infoBitArray[0])[0]) +
Convert.ToString(BitConverter.GetBytes(infoBitArray[1])[0]) +
Convert.ToString(BitConverter.GetBytes(info2BitArray[0])[0]) +
Convert.ToString(BitConverter.GetBytes(info2BitArray[1])[0]);
var result = arrayString.ToCharArray();
Thanks in advance.
source
share