CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2013
    Posts
    3

    Help needed in c#

    Hi, I am a newbie for c# and wanted some help for my on-going assignment. I have a string buffer whereby later need to parse it to a dynamic structure and do data manipulation. For instance, i have input buffer like , "". "822001234abcdefg4567858" -> "822" is in hexa datatype indicating the fields record and length. "822" in binary is "100000100010", which means field1 - length 10 bytes,field7 - length 8 bytes ,field11 - length 2 bytes, are present in this input buffer. I have already a template in place for fileds 1 to 128. How can i dynamically parse these input data into a structure based on the "822" field indicator.
    Example 1: Buffer1 --> "822001234abcdefg4567858" // [Binary 100000100010] // [ field 1,10,7 ]
    Example 2: Buffer2 --> "812001234abcdefg4567858" // [Binary 100000010010] // [field 1,8,11 ]
    Thanks in advance for your expert help and suggestions.
    kl

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help needed in c#

    Not real sure what you are doing, but if the length of each entry (e.g.
    812001234abcdefg4567858) is fixed length, just use the SubString method to read a chunk at a time while working your way through the string buffer.

  3. #3
    Join Date
    Feb 2013
    Posts
    3

    Re: Help needed in c#

    Hi Arjay, thanks very much for your reply, but apparently the substring method will be too tedious since,the input buffer length can be very long,more than 3000 bytes sometimes. Just wandering if can pass the string data to a dynamic structure instead. Thanks..K

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help needed in c#

    Quote Originally Posted by kl@007 View Post
    Hi Arjay, thanks very much for your reply, but apparently the substring method will be too tedious since,the input buffer length can be very long,more than 3000 bytes sometimes. Just wandering if can pass the string data to a dynamic structure instead. Thanks..K
    Is the length of each entry fixed? If so and if the data is in string format, loop through the buffer with SubString.

    As far as the dynamic structure, what did you have in mind?

  5. #5
    Join Date
    Feb 2013
    Posts
    3

    Re: Help needed in c#

    Well, the length of each field is fixed and the substring method would have worked perfectly. Since, my input buffer will defer in total length from time to time, i was thinking of marshalling the buffer straight to a dynamic structure, which will hold each field passed over by the input string and later on, do some data modification and form another string and passing it back to the original source.Hope this will help you to get and idea about the nature of this particular project. Thanks..k

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help needed in c#

    Not really clear on what you are trying to do. If the data is in string form and you need to change it and reform it as a string, then manipulate it as a string. If it arrives in another form (like a byte stream), then work with it as such.

    At the very least solve the problem in one format (such as a string with SubString) and then move on to solving in another format.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured