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

Is arraylist type safe in c#?

1054


What is the use of main method in c#?

1031


Does c# support #define for defining global constants?

1083


What is asenumerable in c#?

953


Explain the role of the datareader class in ado.net connections?

946


Explain what are the steps for creating clr trigger?

959


How can I access the registry from c# code?

1071


How do namespaces work?

1014


Differentiate between the public and private ?

1058


What's your approach to fetch static data in your windows form application?

1071


Can an int be negative c#?

1091


What are the applications of c#?

1829


What is meant by enumerable in c#?

1018


What are the variables in c#?

988


What is assembly version series sequence?

1043