I would like to extract text from a textbox and use it as a hexadecimal:
When someone types in "80" into the textbox, I want to be converted from string to hex "0x80", not "0x38 0x30".
For example, input string "E" will be converted to hex "0E". Not "45".
Sorry if this question has been asked before, all I could find were converting from one type to another (which changes the digits) and that is not what I want.
This is my expected results:
Input: 80 (type string, literally just two digits 80 but in string format)
Expected output: 80 (type byte)
Byte.ParseorConvert.ToByteand several duplicates. Performance depends on what the actual string looks like and what you want to do. Things have changed since the 2010s though with the introduction ofReadOnlySpan<char>which can read characters from a long string without making copies.14; but you've also said that the expected output of "80" is80; do you actually mean that the expected output of "80" is128, i.e.0x80/ "hex 80" ?Debug.Assert(0x80==128)passes, because0x80==128is true. Bot are integer literals representing the same value. You already got the answer you want. All answers produce the same bytes.from what i understand, if i type in 128not, that's not what people said at all