Prev: ComboBox with AutoCompleteMode = SuggestAppend and custom search (Contains)?
Next: Question about sorting
From: Tony Johansson on 21 Apr 2010 08:18 Hi! If I have some bytes that are represented in hex like this. 12, bd,8f,7e,4e,4d. How do I assign all these bytes to a byte array ? If the bytes were represented in decimal I would have been able to use this statement byte[] myBytes = new byte[]{ here I could have specified all the bytes with comma in between }; But now when I have hex it's not possible. I could translate the hax value into decimal but I hope there must be a better way. //Tony
From: Jeff Johnson on 21 Apr 2010 09:37 "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:OVyOOzU4KHA.5588(a)TK2MSFTNGP06.phx.gbl... > If I have some bytes that are represented in hex like this. > 12, bd,8f,7e,4e,4d. How do I assign all these bytes to a byte array ? > If the bytes were represented in decimal I would have been able to use > this statement > byte[] myBytes = new byte[]{ here I could have specified all the bytes > with comma in between }; > > But now when I have hex it's not possible. I could translate the hax value > into decimal but I hope there must be a better way. Define "represented in hex." Do you mean you have a STRING containing hex digits? If so, what does the string look like?
From: Tony Johansson on 21 Apr 2010 13:23 "Jeff Johnson" <i.get(a)enough.spam> skrev i meddelandet news:%236qTZfV4KHA.5416(a)TK2MSFTNGP06.phx.gbl... > "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message > news:OVyOOzU4KHA.5588(a)TK2MSFTNGP06.phx.gbl... > >> If I have some bytes that are represented in hex like this. >> 12, bd,8f,7e,4e,4d. How do I assign all these bytes to a byte array ? >> If the bytes were represented in decimal I would have been able to use >> this statement >> byte[] myBytes = new byte[]{ here I could have specified all the bytes >> with comma in between }; >> >> But now when I have hex it's not possible. I could translate the hax >> value into decimal but I hope there must be a better way. > > Define "represented in hex." Do you mean you have a STRING containing hex > digits? If so, what does the string look like? The string looks like this "12,bd,8f,7e,4e,4d" where each item in this string 12 and db and 8f and so on should be converted to a byte and stored in a byte array. //Tony
From: Willem van Rumpt on 21 Apr 2010 13:30 On 21-4-2010 19:23, Tony Johansson wrote: > > The string looks like this "12,bd,8f,7e,4e,4d" where each item in this > string 12 and db and 8f and so on should be converted to a byte and stored > in a byte array. > What solutions have you tried sofar? Maybe if you post your failed attempts, we can help you solve it. -- Willem van Rumpt
From: Jeff Johnson on 21 Apr 2010 13:32 "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:eGsAedX4KHA.3352(a)TK2MSFTNGP02.phx.gbl... >> Define "represented in hex." Do you mean you have a STRING containing hex >> digits? If so, what does the string look like? > > The string looks like this "12,bd,8f,7e,4e,4d" where each item in this > string 12 and db and 8f and so on should be converted to a byte and stored > in a byte array. Then you need to first use the Split() method with a comma as the delimiter and then run each member of the resulting array through the byte.Parse() method to get a real byte back. Use the overload that takes a numeric format and specify <name of enum which I don't remember>.HexNumber.
|
Next
|
Last
Pages: 1 2 Prev: ComboBox with AutoCompleteMode = SuggestAppend and custom search (Contains)? Next: Question about sorting |