+ 1
Object
I still don't understand what an "object" is 😢. what does it mean an "concrete entity" or "an instance of the class"?
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!
0
It really did help. thank you so much. ^_^
0
thanks a lot @Darko