object a = new Dog();
vs
Dog a = new Dog();
In both cases a.GetType() gives Dog.
Both invoke same constructor (with same hierarchy).
Then can you please tell me the difference between these two statements?
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.
Both create a Dog object. Only the second allows you to directly invoke Dog methods or to otherwise treat it like a dog, such as if you need to pass the object to a method as a parameter of type
Dog(or something in the Dog hierarchy that is more specific than simplyobject).