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.

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between list and dictionary in c#?

837


What does do in c#?

919


What is firstordefault c#?

908


Which is faster dictionary or hashtable?

821


Why singleton is sealed?

822


If I return out of a try/finally in c#, does the code in the finally-clause run?

925


Where test director stores its data ? Database ,Local file etc...? I need to read this data from Visual Studio 2005 c# client. Regards

1834


What is Wrapper class in dot net?

1031


What is icollection in c#?

875


I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?

927


update data in an xml file which resides in solution itself, using silverlight 4.0

1726


Why delegate is used in c#?

887


What is private void in c#?

871


What is the difference between abstract class and interface in c#?

918


What is a constructor in c#?

1305