+ 1

Object

I still don't understand what an "object" is 😢. what does it mean an "concrete entity" or "an instance of the class"?

19th Mar 2017, 3:12 PM
Amir Hossein Karimi
Amir Hossein Karimi - avatar
3 Respostas
+ 2
Well, the Object is something that is abstract. The best example is to take something from the real world. Let's have an example: Car So let's write a class for Car. We can give it some properties, like Make, Name, Type and so on. public class Car { public string Make; public string Name; public string Type; } Now we have a class for Car. In this case we can't do anything with it, we first have to make an instance of the class that we can use. So we do: Car myCar = new Car(); this creates an instance (myCar) of the object Car that we can then use. We can give it a name: myCar.Name = "M3"; And we can say it's a BMW, and it's a sport car: myCar.Make = "BMW"; myCar.Type = "Sport"; So we have an abstract class that represents a real world object, in our case Car. And a BMW M3 Sport is one instance of this object - myCar. Hope this helps. Happy coding!
19th Mar 2017, 8:47 PM
superdarkec
superdarkec - avatar
0
It really did help. thank you so much. ^_^
19th Mar 2017, 9:12 PM
Amir Hossein Karimi
Amir Hossein Karimi - avatar
0
thanks a lot @Darko
20th Mar 2017, 3:02 AM
Alvin Fadli
Alvin Fadli - avatar