What is the difference between TypeOf and GetType?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a template class?

577


Can you declare a class or a struct as constant?

625


What is the main usage of keyword “virtual” ? How does it work for a method or property?

594


what is collections in .net? why we use?

1774


explain the nature of the assembly work?

2209






What is visual c# net?

556


Distinguish between finally and finalize blocks?

595


What is difference between c and c sharp?

548


What is yield return in c#?

567


Define satellite assembly in c#?

568


Is predicate a functional interface?

589


What is concrete class in c# with example?

561


Define satellite Assembly?

650


Is string a primitive data type in c#?

579


What are regular expressions? Search a string using regular expressions?

597