bytes in C#

joecole's Avatar, Join Date: Sep 2008
Newbie Member
            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.
Bitmatic's Avatar, Join Date: Nov 2008
Light Poster
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.