Q:

C# program to print size of various data types

belongs to collection: C# Basic Programs | basics

0

C# program to print size of various data types

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// C# program to C# program to print 
// size of various data types
using System;
using System.IO;
using System.Text;

namespace IncludeHelp
{
    class Test
    {
        // Main Method 
        static void Main(string[] args)
        {
            Console.WriteLine("sizeof(int): {0}", sizeof(int));
            Console.WriteLine("sizeof(float): {0}", sizeof(float));
            Console.WriteLine("sizeof(char): {0}", sizeof(char));
            Console.WriteLine("sizeof(double): {0}", sizeof(double));
            Console.WriteLine("sizeof(bool): {0}", sizeof(bool));

            //hit ENTER to exit the program
            Console.ReadLine();
        }
    }
}

Output

sizeof(int): 4
sizeof(float): 4
sizeof(char): 2
sizeof(double): 8
sizeof(bool): 1

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Basic Programs | basics

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program for type conversion from double to int... >>
<< C# program to demonstrate the example of New keywo...