Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   bytes in C# (http://www.go4expert.com/forums/bytes-c-sharp-t14423/)

joecole 7Oct2008 22:32

bytes in C#
 
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.

Bitmatic 2Nov2008 21:44

Re: bytes in C#
 
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.


All times are GMT +5.5. The time now is 03:50.