Results 1 to 4 of 4

Thread: [RESOLVED] convert string to array

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] convert string to array

    hi,
    string test1; byte[] test2;

    It is posible to convert or parse string to byte array in C#?

    thanks...

    Popskie

  2. #2
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: convert string to array

    I think you need to use the encoding classes: like this:
    Code:
    string test = "Hello World";
    byte [] myByte = Encoding.UTF8.GetBytes(test);
    HTH, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: convert string to array

    hmm I would do Ascii.getbytes

    why utf8? I dont even know what it is
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: convert string to array

    MrPolite is correct there is no utf8 but my problem didnt get here. Ok i explain what i need here. First i hve a fieldtype image. When i retrieve that table my image field is save to listview subitem as string. when the user click that subitem i want to convert that string to byte[] in order to view that image but i got an error here . The error is invalid parameter used or invalid cast. What the problem. I already convert into byte[] but the error stil der.
    Last edited by popskie; Aug 25th, 2005 at 09:13 PM.

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