Size of int, double, char and bool : int « Data Types « C# / C Sharp






Size of int, double, char and bool

Size of int, double, char and bool
    
/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

//
//  Sizes.cs -- returns the sixes of C# data types.
//              Compile with the following command line:
//                  csc /unsafe sizes.cs
//
namespace nsSizes
{
    using System;
    struct TestStruct
    {
        int    x;
        double y;
        char   ch;
    }

    public class Sizes
    {
        static public unsafe void Main ()
        {
            Console.WriteLine ("The size of a bool is " + sizeof (bool));
            Console.WriteLine ("The size of a char is " + sizeof (char));
            Console.WriteLine ("The size of an int is " + sizeof (int));
            Console.WriteLine ("The size of a long is " + sizeof (long));
            Console.WriteLine ("The size of an double is " + sizeof (double));
            Console.WriteLine ("The size TestStruct is " + sizeof (TestStruct));
        }
    }
}

           
         
    
    
    
  








Related examples in the same category

1.Assign value to int variable
2.Call methods from primitive data types
3.Calculating the product of three integers.
4.Comparing integers using if statements, equality operators, and relational operators.
5.demonstrates variablesdemonstrates variables
6.Assing value to int valueAssing value to int value
7.Calculate: int and doubleCalculate: int and double
8.displays a conversion table of Fahrenheit to Celsiusdisplays a conversion  
   table of Fahrenheit to Celsius
9.Some Operator on int
10.Using Integers
11.Using Variables
12.Convert string value to integer by using the int.TryParse
13.Use CultureInfo int ToString method
14.Integer OverFlow
15.Catch OverflowException Exception
16.Do calculation with int variable
17.Format int in Console.WriteLine
18.Use CultureInfo in int.ToString method
19.Use #, % and in int format
20.int based Fahrenheit and Celsius (Centigrade) Scales
21.int array property
22.Parse int value
23.The precision specifier controls the number of significant digits or zeros to the right of a decimal:
24.Int value To Hex char
25.Get the digit-length of an int value
26.Max/Min for int and double values
27.Read sync safe int 32
28.Write Synch safe Int32
29.Calculate average for a list of integer values with params int[] values
30.Int extension Convert integer to boolean, is it even, is it positive
31.Converts an integer into a roman numeral.
32.Get Ordinal
33.Output with x8 format
34.Int32.MaxValue and Int32.MinValue
35.Convert Bytes To UInt
36.Compress UInt
37.Decompress UInt
38.Write Compressed UInt32
39.Read Compressed UInt32
40.Compress Int
41.Is even