So, I have a string of 13 characters.
string str = "HELLOWORLDZZZ";
and I need to store this as ASCII representation (hex) in a uint variable. How do I do this?
You can use Encoding.ASCII
.
GetBytes
to convert your string to a byte
array with ASCII encoding (each character taking one byte
). Then, call BitConverter.ToUInt32
to convert that byte array to a uint
. However, as @R. Bemrose noted in the comments, a uint
is only 4 byte
s, so you'll need to do some partitioning of your array first.