check size with sizeof operator : sizeof « Language Basics « C# / C Sharp






check size with sizeof operator

 
using System;
class MainClass
{
    // unsafe not required for primitive types.
    static void Main()
    {
        Console.WriteLine("The size of short is {0}.", sizeof(short));
        Console.WriteLine("The size of int is {0}.", sizeof(int));
        Console.WriteLine("The size of long is {0}.", sizeof(long));
    }
}

   
  








Related examples in the same category

1.You must declare that code that uses the sizeof operator as unsafe.