Wednesday 16 March 2011

Data-types in C#

Data types in c# is divided into how many parts?

There are 2 types of Data types in c#:
a. Value type
b. Reference type

Examples of Value type data type?

Integer
Enumeration
Structure
characters

Example of Reference type data types?

Object
Strings
Classes
Arrays
Interfaces

What are Value types and Reference types ?

Value types directly contain their data are either allocated on the stack or allocated in-line in a structure.
Reference types store  a reference to the value's memory address, and are allocated on the heap.


Value and Reference type datatypes are further classified into?

a. User Defined
b. Pre Defined

Eg of user defined data types are:
Enum
Struct
Classes
Arrays
Interface

Eg of Pre defined data types are:
Integer
Characters
Object
Strings

Explain the difference between value types and reference types?

Value Type:
a.    Stores the data.
b.    The value of value types is stored on the managed stack.
c.    One variable can have just one value.
d.    They are lighter objects.
Reference Type:
a.    Stores the reference to the data.
b.    A reference type is allocated on the heap.
c.    several variables can reference the same data
d.    They are heavier objects.

No comments:

Post a Comment