bytes in C#

Newbie Member
7Oct2008,22:32   #1
joecole's Avatar
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.
Light Poster
2Nov2008,21:44   #2
Bitmatic's Avatar
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.