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

Name which controls do not have events?

1027


What is static noise?

897


Can you see a loop recorder?

848


What is a service layer c#?

842


What is the difference between do and while loop?

866


Explain about generics in c#.net?

1020


What are c# i/o classes? What are the commonly used i/o classes?

911


Can we customize the serialization process?

943


What are fields in c#?

873


Explain use of abstract and sealed classes in c#?

833


What are the differences between value types and reference types?

1094


Why is .net so popular?

943


Explain boxing and unboxing in c#?

896


Why are c# strings immutable?

950


What does assert() do in c#?

990