C
Join ServerC#
help
❔ what's an object?
SSoinagie2/25/2023
Can somebody please explain to me in very simple words what's an obkect as I don't understand it from explanations on the internet
AAngius2/25/2023
It's a thing
AAngius2/25/2023
A car is an object
AAngius2/25/2023
A desk is an object
AAngius2/25/2023
The chair you're sitting on is an object
AAngius2/25/2023
It's not any different when it comes to programming
SSoinagie2/25/2023
So it's just a variable?
AAngius2/25/2023
No
SSoinagie2/25/2023
Like x=10?
AAngius2/25/2023
A variable is the object's address, you could say
SSoinagie2/25/2023
What address
AAngius2/25/2023
How you refer to that specific object
AAngius2/25/2023
Like, you have a
Car
. But which car do you mean?SSoinagie2/25/2023
I still don't know what objects are
AAngius2/25/2023
var myCar = new Car();
var yourCar = new Car();
SSoinagie2/25/2023
So Im not sure I understand
AAngius2/25/2023
Two different objects, two different cars
AAngius2/25/2023
So each has a different name
AAngius2/25/2023
There's my car, and there's your car
SSoinagie2/25/2023
And they're both new cars?
AAngius2/25/2023
They're both cars
SSoinagie2/25/2023
New cars
AAngius2/25/2023
new
is how you instantiate an object in C#SSoinagie2/25/2023
What
AAngius2/25/2023
How you create a new instance of a car
AAngius2/25/2023
A new instance of an object
SSoinagie2/25/2023
Idk even know what instantiate means😭
AAngius2/25/2023
To create an instance of
AAngius2/25/2023
An individual thing
AAngius2/25/2023
A class, in C#, is sort of a blueprint for a thing. A concept of it, an idea of it
AAngius2/25/2023
Then, from that class, you can create a specific instance
SSoinagie2/25/2023
Why make new instance of a car?
AAngius2/25/2023
A specific, existing, physical object
AAngius2/25/2023
Because you want an actual car
AAngius2/25/2023
Not just an idea of a car
SSoinagie2/25/2023
You already have it just copy it
AAngius2/25/2023
What if both have different colors?
SSoinagie2/25/2023
But you didn't write that anywhere
AAngius2/25/2023
var myCar = new Car("Ford", "Blue");
var yourCar = new Car("Mazda", "Green");
SSoinagie2/25/2023
Im confused
AAngius2/25/2023
And even in the case of
what if I want to start just a specific car?
var myCar = new Car();
var yourCar = new Car();
what if I want to start just a specific car?
AAngius2/25/2023
myCar.Start();
AAngius2/25/2023
I don't want to start the idea of a car
AAngius2/25/2023
I want to start specifically my own car
SSoinagie2/25/2023
What idea?
PPobiega2/25/2023
Are two black fords the same car? no, they are two different instances of a black ford
AAngius2/25/2023
The idea of a thing, the concept of it, not the specific given thing
SSoinagie2/25/2023
What?
AAngius2/25/2023
"A chair" is a general term, a name for the concept of this piece of furniture
AAngius2/25/2023
"A chair" doesn't have colour or shape
AAngius2/25/2023
"The chair" does
AAngius2/25/2023
When I say "chair" it doesn't have colour
AAngius2/25/2023
When I say "my chair" or "your chair" or "that chair over there", they do
AAngius2/25/2023
They're no longer abstract concepts, they're concrete, existing, physical objects
SSoinagie2/25/2023
But only if you put that color in parentheses
AAngius2/25/2023
That's a constructor
AAngius2/25/2023
You can just... not have a constructor, and it can still work
SSoinagie2/25/2023
Sorry I have no idea about the wording and in general Im just lost
AAngius2/25/2023
var myCar = new Car();
var yourCar = new Car();
myCar.Color = "Red";
yourCar.Color = "White";
AAngius2/25/2023
Here, I just set the colour of those cars after creating them
SSoinagie2/25/2023
You just called myCar a variable
SSoinagie2/25/2023
Then isnt it a variable?
AAngius2/25/2023
The variable gives that object a name
SSoinagie2/25/2023
So objects are variables
AAngius2/25/2023
var Soinahie = new Person();
AAngius2/25/2023
No
AAngius2/25/2023
Are you your name?
AAngius2/25/2023
Or are you a person, that has a name we can all use to refer to you?
AAngius2/25/2023
var Pobiega = new Person();
AAngius2/25/2023
Two different people, with two different names
SSoinagie2/25/2023
What pobiega?
AAngius2/25/2023
@Pobiega
AAngius2/25/2023
Another user
PPobiega2/25/2023
👋
SSoinagie2/25/2023
I dont understand
AAngius2/25/2023
You don't understand a difference between a person and their name?
AAngius2/25/2023
We use names if we want to refer to specific people
SSoinagie2/25/2023
But what about my name?
PPobiega2/25/2023
What about it?
AAngius2/25/2023
It's how others can tell you apart from other people?
AAngius2/25/2023
It's how others can refer to you?
SSoinagie2/25/2023
So its indetificator for an object?
AAngius2/25/2023
Yep
PPobiega2/25/2023
in programming we say that "a variable points to an object"
SSoinagie2/25/2023
And its a variable
PPobiega2/25/2023
no
PPobiega2/25/2023
its two different things. One points to the other
SSoinagie2/25/2023
They just used var
PPobiega2/25/2023
a name points to a person
PPobiega2/25/2023
var variableName = new Person();
PPobiega2/25/2023
var variableName
is indeed a variablePPobiega2/25/2023
but
new Person()
is notSSoinagie2/25/2023
Yeah so my identuficator is a variable
PPobiega2/25/2023
yes
SSoinagie2/25/2023
So my name is var
PPobiega2/25/2023
no,
var
is a keywordPPobiega2/25/2023
variableName
is the nameSSoinagie2/25/2023
I meant short for a varaible
PPobiega2/25/2023
okay, then yes
SSoinagie2/25/2023
My name is a variable string