Click here to Skip to main content
15,891,793 members
Home / Discussions / C#
   

C#

 
QuestionCannot seem to be able to write a byte[] to a file Pin
LCI20-Jun-08 7:56
LCI20-Jun-08 7:56 
AnswerRe: Cannot seem to be able to write a byte[] to a file Pin
Giorgi Dalakishvili20-Jun-08 8:06
mentorGiorgi Dalakishvili20-Jun-08 8:06 
AnswerRe: Cannot seem to be able to write a byte[] to a file Pin
leppie20-Jun-08 8:12
leppie20-Jun-08 8:12 
GeneralRe: Cannot seem to be able to write a byte[] to a file Pin
LCI20-Jun-08 8:22
LCI20-Jun-08 8:22 
GeneralRe: Cannot seem to be able to write a byte[] to a file Pin
leppie20-Jun-08 8:27
leppie20-Jun-08 8:27 
GeneralRe: Cannot seem to be able to write a byte[] to a file Pin
LCI20-Jun-08 8:32
LCI20-Jun-08 8:32 
QuestionHex String into number Pin
aman200620-Jun-08 7:26
aman200620-Jun-08 7:26 
AnswerRe: Hex String into number Pin
snorkie20-Jun-08 7:47
professionalsnorkie20-Jun-08 7:47 
GeneralRe: Hex String into number Pin
aman200620-Jun-08 7:56
aman200620-Jun-08 7:56 
GeneralRe: Hex String into number Pin
snorkie20-Jun-08 8:05
professionalsnorkie20-Jun-08 8:05 
GeneralRe: Hex String into number Pin
leppie20-Jun-08 8:17
leppie20-Jun-08 8:17 
GeneralRe: Hex String into number Pin
snorkie20-Jun-08 8:21
professionalsnorkie20-Jun-08 8:21 
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 

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.