C# program to print size of various data types

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

using System.Threading;

using System.IO;


namespace CSharpProgram

{

    class AkbTechie

     {

           static void Main(string[] args)

            {

                    //size in Bytes

                    Console.WriteLine("sizeof(int): {0}", sizeof(int));

                    Console.WriteLine("sizeof(long): {0}", sizeof(long));

                    Console.WriteLine("sizeof(float): {0}", sizeof(float));

                    Console.WriteLine("sizeof(double): {0}", sizeof(double));

                    Console.WriteLine("sizeof(decimal): {0}", sizeof(decimal));

                    Console.WriteLine("sizeof(char): {0}", sizeof(char));

                    Console.WriteLine("sizeof(bool): {0}", sizeof(bool));

                    Console.ReadKey();           

            }

    }

}


output:-

sizeof(int): 4

sizeof(long): 8

sizeof(float): 4

sizeof(double): 8

sizeof(decimal): 16

sizeof(char): 2

sizeof(bool): 1


एक टिप्पणी भेजें

0 टिप्पणियाँ