I came across this code :
int myInt = 0;
textBox1.Text = myInt.GetType().Name;
According to the .NET documentation, GetType() is a method, not a class.
My question is that how am I able to use the dot with a method, like this GetType().Name?
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.
A method can return a class instance, here it´s an instance of the class
Type. On this object you can access properties, other methods, etc.Your code could be written as this:
Maybe it´s easier to understand that way.
Edit:
A method call like
GetType()executes the method, and everything you do after the.applies to the return value of the method, in this case an object of typeType.