1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

bytes in C#

Discussion in 'C#' started by joecole, Oct 7, 2008.

  1. joecole

    joecole New Member

    Joined:
    Sep 10, 2008
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Code:
     
                Console.WriteLine(sizeof(long));
                
                long a = long.MaxValue;
                byte[] tmp = ASCIIEncoding.ASCII.GetBytes(a.ToString());
                foreach (byte item in tmp2)
                {
                    Console.Write(item + "; ");
                } 
    Please help me:
    sizeof(long) is 8, but why does tmp have more than 8 elements.
     
  2. Bitmatic

    Bitmatic New Member

    Joined:
    Nov 2, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    Because the number in "a" has 19 digits.

    a.ToString() returns a string that is 19 bytes long, so tmp becomes 19 elements long too.
     

Share This Page