By 22/07/2015 10 Comments

C# sizeof Operator

  • The sizeof operator determines the size of a value type data type.
  • It returns the size in bytes.

Example:

using System;
namespace csharpBasic
{
    // Start class definition / declaration.
    class Program
    {
        // Static main method void type declaration.
        static void Main(string[] args)
        {
            /* Use the sizeof() operator, it passes different data types
               which indicates their size in bytes.
            */ 
            Console.WriteLine("double has "+sizeof(double)+ " bytes.");
            Console.WriteLine("float has "+sizeof(float)+ " bytes.");

            Console.WriteLine("int has " + sizeof(int) + " bytes.");
            Console.WriteLine("long has " + sizeof(long) + " bytes.");

            Console.WriteLine("byte has " + sizeof(byte) + " byte.");
            Console.WriteLine("char has " + sizeof(char) + " bytes.");

            Console.WriteLine("bool has " + sizeof(bool) + " byte.");
            Console.ReadKey();

        } // End of main method definition. 
    } // End of class. 
}





Next Tutorial →


← Previous Tutorial


Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .