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 and GetType?

Answers were Sorted based on User's Feedback



What is the difference between TypeOf and GetType?..

Answer / brijen.patel

TypeOf and GetType Produce the same information but the
difference is where they get theis 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. Whereas GetType is used to
get the type based on as object (an instance of a class)
means GetType needs parameter of object rather than class name.

Is This Answer Correct ?    18 Yes 0 No

What is the difference between TypeOf and GetType?..

Answer / chirag

GetType is a call that is made at runtime on an instance of
an object.
typeof() is resolved to a call at runtime, but loads the
type from the token
for the type. They probably resolve to the same call, it's
just that
GetType requires an instance. If I didn't need the instance,
I would use
typeof.

Is This Answer Correct ?    3 Yes 0 No

What is the difference between TypeOf and GetType?..

Answer / saurabh

TypeOf(): It is an operator, which used to find the type of known type at the time of compilation of the program. It depends on the class or type and cannot pass the object or instance of the class as a parameter to the TypeOf() operator.
GetType(): This is the method, using this method we can obtain the type of the object or the type of instance of the class. To call this method we need an object or an instance of a class.

Is This Answer Correct ?    0 Yes 0 No

What is the difference between TypeOf and GetType?..

Answer / avinash reddy r

typeOf is based on a class

Ex: Console.WriteLine(typeof(int))
O/P: System.Int32


GetType is based on a object

string s="Hello World"

Ex: Console.WriteLine(s.GetType())

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Sharp Interview Questions

From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?

0 Answers  


What is meant by generics in c#?

0 Answers  


Why we need get set property in c#?

0 Answers  


What is clr in c#?

0 Answers  


What is get set in c#?

0 Answers  


Explain constructor in c#?

1 Answers  


What is the difference between finalize() and dispose()?

0 Answers  


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

0 Answers  


Is equal in c#?

0 Answers  


Is int a struct in c#?

0 Answers  


Differentiate between static class and singleton instance?

0 Answers  


Is c and c# the same?

0 Answers  


Categories