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

C#

 
GeneralRe: A Question Of Structure Pin
Alan Balkany12-Apr-12 4:34
Alan Balkany12-Apr-12 4:34 
GeneralRe: A Question Of Structure Pin
Jason McBurney12-Apr-12 14:14
Jason McBurney12-Apr-12 14:14 
GeneralRe: A Question Of Structure Pin
Roger Wright12-Apr-12 19:47
professionalRoger Wright12-Apr-12 19:47 
AnswerRe: A Question Of Structure Pin
Big Daddy Farang11-Apr-12 10:14
Big Daddy Farang11-Apr-12 10:14 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 21:52
professionalRoger Wright11-Apr-12 21:52 
AnswerRe: A Question Of Structure Pin
PIEBALDconsult11-Apr-12 11:30
mvePIEBALDconsult11-Apr-12 11:30 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 21:58
professionalRoger Wright11-Apr-12 21:58 
AnswerRe: A Question Of Structure Pin
Pete O'Hanlon11-Apr-12 12:33
mvePete O'Hanlon11-Apr-12 12:33 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 22:02
professionalRoger Wright11-Apr-12 22:02 
AnswerRe: A Question Of Structure Pin
RCoate11-Apr-12 18:11
RCoate11-Apr-12 18:11 
JokeRe: A Question Of Structure Pin
PIEBALDconsult11-Apr-12 18:52
mvePIEBALDconsult11-Apr-12 18:52 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 20:41
professionalRoger Wright11-Apr-12 20:41 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 22:08
professionalRoger Wright11-Apr-12 22:08 
AnswerRe: A Question Of Structure Pin
Ravi Bhavnani11-Apr-12 18:44
professionalRavi Bhavnani11-Apr-12 18:44 
AnswerRe: A Question Of Structure Pin
Eytukan11-Apr-12 20:52
Eytukan11-Apr-12 20:52 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 21:37
professionalRoger Wright11-Apr-12 21:37 
AnswerRe: A Question Of Structure Pin
Mycroft Holmes11-Apr-12 21:21
professionalMycroft Holmes11-Apr-12 21:21 
GeneralRe: A Question Of Structure Pin
Roger Wright11-Apr-12 21:51
professionalRoger Wright11-Apr-12 21:51 
GeneralRe: A Question Of Structure Pin
PIEBALDconsult12-Apr-12 3:00
mvePIEBALDconsult12-Apr-12 3:00 
GeneralRe: A Question Of Structure Pin
Roger Wright12-Apr-12 5:18
professionalRoger Wright12-Apr-12 5:18 
AnswerRe: A Question Of Structure Pin
BobJanova11-Apr-12 23:57
BobJanova11-Apr-12 23:57 
QuestionConverting special string array into two different byte arrays Pin
MichCl11-Apr-12 8:22
MichCl11-Apr-12 8:22 
AnswerRe: Converting special string array into two different byte arrays Pin
PIEBALDconsult11-Apr-12 9:41
mvePIEBALDconsult11-Apr-12 9:41 
GeneralRe: Converting special string array into two different byte arrays Pin
MichCl11-Apr-12 10:11
MichCl11-Apr-12 10:11 
AnswerRe: Converting special string array into two different byte arrays Pin
OriginalGriff11-Apr-12 9:50
mveOriginalGriff11-Apr-12 9:50 
Here is a quick and dirty way:

C#
    ...
    string[] dataString = { "40 A8", "AA A8", "00 4E" };
    byte[] bytes = ConvertToBytes(dataString);
    ...
private byte[] ConvertToBytes(string[] data)
    {
    List<byte> bytes = new List<byte>();
    foreach (string line in data)
        {
        string[] values = line.Split(' ');
        foreach (string value in values)
            {
            bytes.Add(byte.Parse(value, System.Globalization.NumberStyles.HexNumber));
            }
        }
    return bytes.ToArray();
    }
In the real world, you'd want error checking, and probably to look at the efficiency a bit if it is going to be used a fair amount - that isn't very efficient at all.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

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.