Explain the data types in C#

  • Value Type: Value types, which stores its value directly include all numerical data types (int, float, etc), as well as enumerations and structures, and are allocated on the stack (although if value types are declared as fields within reference types, they will be stored inline on the heap). Value types can be quickly removed from memory once they fall out of the defining scope. When a value type is assigned to another, a member-by-member copy is achieved by default.
  • Reference Type: A reference type stores a reference to the value. Reference types are stored in managed heap. If a reference is set to null, then it is not possible to call any non-static member functions or fields against it; doing so would cause an exception to be thrown at runtime. 
Note: C# has 15 predefined types, 13 value types, and 2 (string and object) reference types.

1 comment:

  1. Dapfor provide a net grid which is very useful and informative.you can read from dapfor. com