33 Replies
Wdym? Do you have a code snippet to show? It depends on the context
like, I have a hard time understanding what it does, I get the gist of it but I don't know
Well I asked you to be more specific cus the keyword can be applied differently depending on the context, but I’ll assume you’re referring to the most common usage, which is the new operator
Well, i don’t really know what else to say, but it’s used alongside a type’s constructor to create a new instance of this type
oh
like
variables
example: string smth = new string[];
Something like
Here the new keyword is being used alongside the default constructor for List<int> to create a new instance of List<int> and to return a reference to it to the variable foo
what does it do in the line of code
liek
like*
It creates the instance of the type, what data the instance will have will depend on what constructor is used
Which is usually after the new keyword
erhhhhhhhh I am stupid
so it just like, makes it smth that's not the other thing
Also it should be string[] smth = new string[insert a number here];
ik
I am tired
Sorry
not ur fault
My choice to sleep deprive myself over this
Okay okay, depending on whatever constructor is used after the keyword, it will return an instance of whatever type the constructor belongs to
uhhh what is the contrustor?
I forgot
What comes after new, it’s a special function that’s used to initialize instance data
ohhhhh
so like
how much it holds or smth
?
The constructor you use determines what data the instance will hold initially
So not how much, but what it holds
oh
so like
think of it as a container?
The instance is the container, the constructor determines what’s in the container initially
And the new keyword creates the container
ok so sorry for wasting your time but
Nah don’t apologize I feel bad I am not explaining better
I can send documents if they’d help
Official Microsoft ones
No your explaining fine I just like, have harder time understanding bigger words
like for a example, you said did The outrageous courageous lion decided to do a malicious deed to capture it's prey.
I'd probably need to hear it again
to understand
Oh? I did not say that unless I am missing something
figuratively
Oh you’re saying I said a lot of stuff that isn’t easy to understand?
yup
Ah I see
new operator - Create and initialize a new instance of a type - C#
The C# new operator is used to create a optionally initialize a new instance of a type.
ok thx
one more thing
Like stuff like this: Represents the standard input, output, and error streams for console applications. This class cannot be inherited. I could not understand unless I built a personal meaning of it in my mind.
Hmmm, you’d have to start from scratch to build a foundation to understand stuff like that
that's why I make notes
it's like a training book specifically for me to help ME understand the best way to understand it.
I think that’s good then if it helps you understand better
It’s easy to get lost though so don’t be too hard on yourself
Or maybe I'm just slow. 🥱😭