Convert byte[] to system.type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vipul
    New Member
    • Apr 2012
    • 2

    Convert byte[] to system.type

    hi
    I want to convert byte[] to system.type data type
    I want su ch a functionality like convrt byte[] to any tye passed by user

    Is it possible to do that?
  • RhysW
    New Member
    • Mar 2012
    • 70

    #2
    yes with a bit of work, i can see two ways of doing this, first of all you could either get them to specify a type from the beginning, e.g you want hem all to be ints, then you just set up a loop that goes through each entry in the array and uses convert.toint32 (byte[i]). then store the converted data into another list or whatever you want to do with it, alternately you could let them pick one member from the list and convert that to what they choose, e.g, they pick entry 4, and want it to be an int, you just do a switch statement, like so

    EDIT: after looking about a bit it would be best to follow the idea in this thread, convert it to ASCII version of a string every time then turn that into an int if it is viable, better than my original idea
    The home for technical questions and answers at Microsoft. Get started asking, answering, and browsing questions about products like .Net, Azure, or Teams.
    Last edited by RhysW; Apr 18 '12, 10:12 AM. Reason: Much better answer found

    Comment

    Working...