Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / konduru bhaskar raju

typeof and GetType produce the exact same information. But
the difference is where they get this information from:

typeof is used to get the type based on a class. That means
if you use typeof with object, it will gives you error. You
must pass class as parameter parameter.
Where GetType is used to get the type based on an object
(an instance of a class). Means GetType needs parameter of
object rather than class name.
You can understand more with example.

The following code will output “True”:

string instance = “”;

Type type1 = typeof(string);

Type type2 = instance.GetType();

Console.WriteLine(type1 == type2);

Is This Answer Correct ?    15 Yes 5 No

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

Answer / 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

More C Sharp Interview Questions

What does exclamation mark mean in access query?

0 Answers  


Which CSS property can be used for controlling the stretchiness of a control?

1 Answers   TCS,


How the versioning applies to Assemblies or can you explain version numbers?

0 Answers   CitiusTech,


What is an array class?

0 Answers  


What is the difference between dynamic type variables and object type variables in c#?

0 Answers  


How do I run managed code in a process?

0 Answers  


why c# is pronounced as C-sharp instead of pronouncing it as C-hash? is there any technical reason behind it?

3 Answers  


What is the meaning of int parse in c#?

0 Answers  


What is multicast delegate explain with example?

0 Answers  


What is the minimum size (in bytes) of string data type in c#? Give its compatible data type in .NET Framework.

5 Answers  


Explain About multi level and multiple inheritance how to achieve in .net

0 Answers  


explain the features of static/shared classes.

0 Answers  


Categories