What is the use of sizeof Operator in C#?

CsharpProgrammingServer Side Programming

The sizeof() datatype returns the size of a data type. Let’s say you need to find the size of int datatype −

sizeof(int);

For double datatype −

sizeof(double);

Let us see the complete example to find the size of various datatypes −

Example

 Live Demo

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {

         Console.WriteLine("The size of long is {0}", sizeof(long));
         Console.WriteLine("The size of double is {0}", sizeof(double));

         Console.ReadLine();
      }
   }
}

Output

The size of long is 8
The size of double is 8
raja
Published on 08-Aug-2018 10:18:17
Advertisements