Possible Duplicate:
Difference between object and instance
I have couple of questions:
Could anyone help me better understand the above concepts as they relate to C#?
class Cat {} // It is a cat. Just a cat. Class is a general issue.
myCat = new Cat("red", "5kg", "likes milk", "3 years old"); // It is my cat. It is an object. It is really a cat.
yourCat = new Cat("gary", "3kg", "likes a meal", "5 years old"); // It is your cat. Another cat. Not my cat. It is really a cat too. It is an object;
abstract class Animal {} // Abstract class
animal = new Animal(); // It is not correct. What is 'animal'? Cat, dog, cow? I don't know.
class Dog : Animal {} // It is a class. It is a dog in general.
someDog = new Dog("brown", "10 kg", "likes cats"); // It is really a dog. It is an object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With