I don’t understand when to use the typeof() operator? In what context is it good to use it?
I don’t understand when to use the typeof() operator? In what context is it
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is like .GetType() except it works on a type name instead of an instance.
You would use typeof(MyType) if you need to get an instance of System.Type and you know the type at compile time. You don’t need an instance of that type for resolve the description of that type (System.Type).
Eg if you had an instance you would:
But you could: