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

image_pdfimage_print
   
  
class SomeClass
{
    static unsafe public void ShowSizes() 
    {
        Console.WriteLine("
Basic type sizes");
        Console.WriteLine("sizeof short = {0}", sizeof(short));
        Console.WriteLine("sizeof int = {0}", sizeof(int));
        Console.WriteLine("sizeof long = {0}", sizeof(long));
        Console.WriteLine("sizeof bool = {0}", sizeof(bool));
    }
}
   
class SizeofBasicTypesApp
{
    unsafe public static void Main(string[] args) 
    {
        SomeClass.ShowSizes();
    }
}