Difference between TypeOf() and GetType() in C#

TypeOf: is an operator to obtain a type known at compile-time (or at least a generic type parameter). The operand of TypeOf is always the name of a type or type parameter - never an expression with a value (e.g. a variable). See the C# language specification for more details.

GetType : is a method you call on individual objects, to get the execution-time type of the object.

result is

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Alireza Farokhi
Alireza Farokhi

No responses yet

Write a response