Records of a 24-byte byte: xx xx xx xx xx xx xx xx xx xx xx xx
I have a record with a 24-character byte in a text box with different write requirements in the byte segment, do I have a template code for dynamically encoding the range of hexadecimal values that is required for each segment, for example. 14?
I tried the code below, but that’s not what I wanted, as it converts the entire hexadecimal notation to the int equivalent, without giving me the freedom to encode the range I wanted.
outputTxt.Text = String.Join(" ",
hexTextBox.Text.Trim().Split(' ').Select(item => Convert.ToInt32(item, 16)));
For example, the first group of 2 hexadecimal values entered in a text field, the function for checking the entered hexadecimal value is between 0 and 100 in uint before converting it to the decimal equivalent in the output text field, otherwise it will display “Error” in the output text field .
Subsequently, the next 4 bytes, I only allow 4 bytes of hexadecimal entries in the range -1000 to 1000 in int else. Displays an error message.
EDIT: Sorry for the confusion as I expressed my suggestions before, since 5 bytes is just a byte representation of the ASCII character for each byte with a range from 0 to 255. How to encode these different cases? Thank!
uint value1 = reader.ReadByte();
if (value1 ==700)
{
OutputTxt.Text = value1.ToString();
OutputTxt.Text +="\n";
}
else
{
OutputTxt.Text = "Error"
OutputTxt.Text +="\n";
}
uint value2 = reader.ReadByte();
if (value2 <=1000)
{
OutputTxt.Text += value2.ToString();
OutputTxt.Text +="\n";
}
else
{
OutputTxt.Text += "Error"
OutputTxt.Text += "\n";
}
, , , readByte()?