开发者

Add byte to array removes capitalized letters

开发者 https://www.devze.com 2023-01-22 16:11 出处:网络
I try to add a byte to an array as shown below: messagedata.Add((开发者_StackOverflowbyte)0xF0); But then when I check the array, the item looks like 0xf0 but it since it\'s going to be a MIDI mess

I try to add a byte to an array as shown below:

messagedata.Add((开发者_StackOverflowbyte)0xF0);

But then when I check the array, the item looks like 0xf0 but it since it's going to be a MIDI message I found it has to be a capital F. What can I do to keep the letters capitalized?


It's not possible to keep the letter capitalized, because the letters aren't stored in the array. The only thing stored in the array is a numerical value, and 0xf0 is just one of the way to represent that value as text.

You don't need to keep the letter capitalized. A MIDI message is sent as bytes, not text, so 0xf0 and 0xF0 are textual representations of the same value. There are other ways to represent the same value as text, as 240, 0360 or %11110000, and they all mean the same thing.

This code:

messagedata.Add((byte)240);

produces the exact same result as your code above. The executable code will be identical, and it's not possible to determine which code was used by examining the compiled code.


0xF0 and 0xf0 are the same thing. When you look and see 0xf0 (with a debugger or whatever) that tool simply decided to use lower case letters. F and f both mean 4 bits all equal to 1

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号