What is the difference between TypeOf, GetType and what are
the uses of TypeOf, GetType.

Answer Posted / rajesh marripalli

In simple words, all value based types are allocated on the
stack, while all reference based types are allocated on the
heap. What does this mean? A value type contains the actual
value. A reference type contains a reference to the value.
When a value type is assigned to another value type, it is
copied. When a reference type is assigned to another
reference type, a reference is assigned to the value.

By saying stack, we mean things are kept one on top of the
other. We keep track of each value at the top. By saying
heap, we mean things are kept in a mashed order. We keep
track of each value by its address that is referenced by a
pointer to it.

All value types are implicitly derived from
System.ValueType. This class actually overrides the
implementation in System.Object, the base class for all
objects which is a reference type itself.

Data types like integers, floating point numbers, character
data, Boolean values, Enumerations and Structures are
examples of Value Types. Classes, Strings, Arrays are
examples of Reference Types.

A value type may not contain NULL values. Reference types
may contain NULL values.

It is not possible to derive new types from Value Types.
This is possible in Reference types. However, Value Types
like Structures can implement interfaces.

Is This Answer Correct ?    2 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are verbatim strings in c#?

495


What is jit? What are the different types of jit?

571


Can the accessibility of a type member be greater than the accessibility of its containing type?

562


What is generic and non generic collections in c#?

437


Is and as in c#?

511






Explain the process of polymorphism with an example?

476


Is datetime value type c#?

483


How can encapsulation be achieved?

601


Overloaded constructor will call default constructor internally?

565


In .Net, what is an assembly? Also explain the type of assembly.

519


What is form feed and carriage return?

483


Explain how do I convert a string to an int in c#?

515


What is primitive types in c#?

466


What is difference between an Structure and Class?

567


What is the advantage of constructor?

476