Results 1 to 5 of 5

Thread: ToString Help[resolved]

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    ToString Help[resolved]

    Code:
    byte b;
    string s ="";
    
    for(int i = 0; i < Stream.Length; i++)
    {
        b = (byte)Stream.ReadByte();
        s += b.ToString("g");
    }
    I want ascci text to come out but all I get are numbers. Can anyone tell me about why and what to do. the Stream is from a text file that contains ascii text. I'm confused because I swear when I was using System.Console and reading it I used ToString("g").....
    Last edited by Magiaus; Apr 1st, 2004 at 08:08 AM.
    Magiaus

    If I helped give me some points.

  2. #2

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    Code:
    byte b;
    string s ="";
    
    for(int i = 0; i < Stream.Length; i++)
    {
        s += (char)Stream.ReadByte();
    }
    I'm knew I shouldn't have had that 12 pack with lunch.....
    Last edited by Magiaus; Apr 1st, 2004 at 08:07 AM.
    Magiaus

    If I helped give me some points.

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    btw how come the second line doesnt end with a semi-colon and then the line inside the forloop has two semi-colons?
    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
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    because I just typed it in. The first post should also have a (byte) cast on ReadByte because it returns an int.
    Magiaus

    If I helped give me some points.

  5. #5

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    ok all fixxed
    Magiaus

    If I helped give me some points.

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