✅ new
I've seen people write code like this and I was wondering what it does and what it is called. An example is,
apple apple = new apple();
if you know what this is, please help me.
10 Replies
it's called object creation
it allocates memory for an object of the type after
new
and then calls its constructorI suggest you start following a basic c# tutorial considering this is the second question I see posted from you that a tutorial would explain
It's also known as object instantiation. You have an object
class Apple
that has a default .ctor
(read: constructor) that is Apple()
and that creates/instantiates a new instance of Apple
.There will be a lot you have to learn, and asking it all here makes no sense
thanks
what can u do with these instances tho?
it's memory
it's for remembering values of stuff
but cant we just use variables?
through types you can group multiple variables sorta
ohhhh
ok tysm
np