How to get the size of data type in C#

How to get the size of data type in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sizevalue
{
    class Program
    {
        static void Main(string[] args)
        {
          
            Console.WriteLine("Size of int   "+sizeof(int));
            Console.WriteLine("Size of Int32   " + sizeof(Int32));
            Console.WriteLine("Size of float   " + sizeof(float));
            Console.WriteLine("Size of decimal   " + sizeof(decimal));
            Console.WriteLine("Size of bool   " + sizeof(bool));
            Console.WriteLine("Size of Byte   " + sizeof(Byte));
            Console.WriteLine("Size of DateTimeKind   " + sizeof(DateTimeKind));
            Console.WriteLine("Size of Double   " + sizeof(Double));
            Console.WriteLine("Size of double   " + sizeof(double));
            Console.ReadLine();
        }
    }
}

output here:-











Share this

Previous
Next Post »