Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

SIZEOF( ) in C#

The sizeof( ) operator tells you the number of bytes allocated for data items.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12.  
  13. Console.WriteLine(sizeof(int));
  14. Console.WriteLine(sizeof(short));
  15. Console.WriteLine(sizeof(float));
  16. Console.WriteLine(sizeof(long));
  17. Console.WriteLine(sizeof(double));
  18. Console.WriteLine(sizeof(decimal));
  19. Console.WriteLine(sizeof(char));
  20. }
  21. }
  22. }


Output:
  1. 4
  2. 2
  3. 4
  4. 8
  5. 8
  6. 16
  7. 2


..