C
C#2mo ago
mich4s

whats this, is this just console or .net console when creating a new project with visual studio 22?

No description
33 Replies
mich4s
mich4sOP2mo ago
yeah
Pobiega
Pobiega2mo ago
Thats the old default program template for console apps, yes Did you perhaps accidentally pick .net framework?
mich4s
mich4sOP2mo ago
is it the .net one or normal console app i created it using cmd like dotnet new console --use-program-main thats what we have been doing
Pobiega
Pobiega2mo ago
Ah on Yeah then its modern .net
mich4s
mich4sOP2mo ago
so is it good or no? im new to c#
Pobiega
Pobiega2mo ago
Yes
mich4s
mich4sOP2mo ago
No description
mich4s
mich4sOP2mo ago
what about when i create from this which one should i pick
Pobiega
Pobiega2mo ago
Top good, bottom bad
mich4s
mich4sOP2mo ago
can u explain why is that?
Pobiega
Pobiega2mo ago
.net framework is old and legacy It was discontinued in 2016
mich4s
mich4sOP2mo ago
then what did i create from my console the top one?
Pobiega
Pobiega2mo ago
Yws
mich4s
mich4sOP2mo ago
is it with top level statements?
Pobiega
Pobiega2mo ago
No, you explicitly opted for the program main instead
mich4s
mich4sOP2mo ago
No description
mich4s
mich4sOP2mo ago
what is this?
Pobiega
Pobiega2mo ago
That's what --use-program-main does Ignore NAOT as a beginner It's an advanced thing
mich4s
mich4sOP2mo ago
okay okay @Pobiega i have one more question though
mich4s
mich4sOP2mo ago
No description
mich4s
mich4sOP2mo ago
why do visual studio (left) and console (right) create a different thing inside? or just anyone who can answer, thanks
Pobiega
Pobiega2mo ago
It doesn't Those are the same
mich4s
mich4sOP2mo ago
i guess they work the same but there are some slight differences
Pobiega
Pobiega2mo ago
The left just has aN explicit access modifier
mich4s
mich4sOP2mo ago
can u talk more humanish?
Pobiega
Pobiega2mo ago
But the default access for classes is internal
mich4s
mich4sOP2mo ago
thats still too not humanish
Pobiega
Pobiega2mo ago
Google C# access modifiers Or take my word for it, it's the same
mich4s
mich4sOP2mo ago
so it doesnt matter that there is a slight difference @Pobiega
Dinosaure
Dinosaure2mo ago
The namespace is file-bound on the right, block-bound on the left. It doesn’t change the code, and removes one indentation layer. Plus, as stated by @Pobiega, your Program is explicitly set to internal on the left, while kept implicitly internal (by default) on the right. So both are the same code.
Pobiega
Pobiega2mo ago
Classes are internal by default, not private
Dinosaure
Dinosaure2mo ago
Thanks for the reminder, both are strictly equivalent.
Pobiega
Pobiega2mo ago
In a single-class project such as this, yes, but its still worth knowing. Private classes are extremely rare, while internal are quite common.
Want results from more Discord servers?
Add your server