One, C # sizeof operator
The sizeof operator is used to get the number of bytes of a value type.
Ii. examples
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Test
{
Class Program
{
static void Main (string[] args)
{
C # sizeof operator-www.baike369.com
Console.WriteLine (the number of bytes SByte is: "+ sizeof (sbyte) +" bytes ");
Console.WriteLine ("Byte number of bytes is:" + sizeof (Byte) + "byte");
Console.WriteLine ("Short" bytes are: "+ sizeof (short) +" bytes ");
Console.WriteLine (the number of bytes UShort is: "+ sizeof (ushort) +" bytes ");
Console.WriteLine (the number of bytes in int is: "+ sizeof (int) +" byte ");
Console.WriteLine ("The number of bytes in float is:" + sizeof (float) + "byte");
Console.WriteLine ("Number of bytes of double is:" + sizeof (double) + "byte");
Console.WriteLine (the number of bytes in char is: "+ sizeof (char) +" byte ");
Console.WriteLine ("BOOL byte number is:" + sizeof (BOOL) + "byte");
Console.ReadLine ();
}
}
}
Operation Result:
The number of bytes SByte is: 1 bytes
The byte count of byte is: 1 bytes
The number of bytes in short is: 2 bytes
The number of bytes UShort is: 2 bytes
The number of bytes in int is: 4 bytes
The number of bytes in float is: 4 bytes
The number of bytes in double is: 8 bytes
The number of bytes in char is: 2 bytes
The number of bytes in bool is: 1 bytes
C # sizeof operator