Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hex String into number Pin
leppie20-Jun-08 8:29
leppie20-Jun-08 8:29 
GeneralRe: Hex String into number Pin
snorkie20-Jun-08 8:40
professionalsnorkie20-Jun-08 8:40 
GeneralRe: Hex String into number Pin
Brady Kelly20-Jun-08 8:57
Brady Kelly20-Jun-08 8:57 
JokeRe: Hex String into number Pin
Spacix One20-Jun-08 9:23
Spacix One20-Jun-08 9:23 
GeneralRe: Hex String into number Pin
aman200620-Jun-08 8:46
aman200620-Jun-08 8:46 
AnswerRe: Hex String into number Pin
leppie20-Jun-08 8:19
leppie20-Jun-08 8:19 
AnswerRe: Hex String into number Pin
Luc Pattyn20-Jun-08 9:13
sitebuilderLuc Pattyn20-Jun-08 9:13 
AnswerRe: Hex String into number Pin
carbon_golem20-Jun-08 9:16
carbon_golem20-Jun-08 9:16 
I'd convert the hex digits into a byte array, figure out what your target Type is, pad/swap as necessary. 24 bit types are a curse on the land handed down from angry gods to punish us for the sins of BIT-BANGERS.... sorry.... Dead | X|

class Program {
       static void Main(string[] args) {
           String s = "100000";
           Byte[] temp = new Byte[4]; // int needs 4 bytes
           Array.Copy(GetBytes(s), 0, temp, 0, 3); // copy in the byte converted string
           Int32 value = BitConverter.ToInt32(temp, 0); // use BitConverter to change
           Console.WriteLine(value.ToString()); // format
           Console.ReadLine(); // wait for non-google searching OP to push something
       }

       public static byte[] GetBytes(string hexFormat) {
           int byteLength = hexFormat.Length / 2;
           byte[] bytes = new byte[byteLength];
           for (int i = 0; i < byteLength; i++) {
               bytes[i] = AsciiAsHexToByte(new String(new Char[] { hexFormat[i * 2], hexFormat[i * 2 + 1] }));
           }
           return bytes;
       }

       public static byte AsciiAsHexToByte(string hex) {
           return byte.Parse(hex, NumberStyles.HexNumber, NumberFormatInfo.CurrentInfo);
       }

   }


As you can see, it's a pain to do the conversion.

Scott P

“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra

AnswerRe: Hex String into number [modified] Pin
Spacix One20-Jun-08 10:11
Spacix One20-Jun-08 10:11 
GeneralRe: Hex String into number Pin
Guffa20-Jun-08 12:55
Guffa20-Jun-08 12:55 
GeneralRe: Hex String into number Pin
Spacix One23-Jun-08 3:37
Spacix One23-Jun-08 3:37 
QuestionSending Text to the Active Control in the Active Application Pin
Dirso20-Jun-08 7:21
Dirso20-Jun-08 7:21 
AnswerRe: Sending Text to the Active Control in the Active Application Pin
DaveyM6920-Jun-08 11:25
professionalDaveyM6920-Jun-08 11:25 
GeneralRe: Sending Text to the Active Control in the Active Application Pin
Dirso20-Jun-08 12:48
Dirso20-Jun-08 12:48 
AnswerRe: Sending Text to the Active Control in the Active Application Pin
mav.northwind20-Jun-08 21:43
mav.northwind20-Jun-08 21:43 
QuestionUpdate Manager Pin
spelltwister20-Jun-08 7:01
spelltwister20-Jun-08 7:01 
AnswerRe: Update Manager Pin
leppie20-Jun-08 7:05
leppie20-Jun-08 7:05 
QuestionHow can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 6:58
Mohammad Dayyan20-Jun-08 6:58 
AnswerRe: How can we remove specific node in the XML file by LINQ? Pin
leppie20-Jun-08 7:02
leppie20-Jun-08 7:02 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 7:20
Mohammad Dayyan20-Jun-08 7:20 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
leppie20-Jun-08 8:05
leppie20-Jun-08 8:05 
GeneralRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 9:09
Mohammad Dayyan20-Jun-08 9:09 
AnswerRe: How can we remove specific node in the XML file by LINQ? Pin
Mohammad Dayyan20-Jun-08 9:13
Mohammad Dayyan20-Jun-08 9:13 
QuestionPacket issues Pin
see_seA20-Jun-08 5:15
see_seA20-Jun-08 5:15 
AnswerRe: Packet issues Pin
leppie20-Jun-08 5:34
leppie20-Jun-08 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.