C
C#2w 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
mich4s2w ago
yeah
Pobiega
Pobiega2w ago
Thats the old default program template for console apps, yes Did you perhaps accidentally pick .net framework?
mich4s
mich4s2w 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
Pobiega2w ago
Ah on Yeah then its modern .net
mich4s
mich4s2w ago
so is it good or no? im new to c#
Pobiega
Pobiega2w ago
Yes
mich4s
mich4s2w ago
No description
mich4s
mich4s2w ago
what about when i create from this which one should i pick
Pobiega
Pobiega2w ago
Top good, bottom bad
mich4s
mich4s2w ago
can u explain why is that?
Pobiega
Pobiega2w ago
.net framework is old and legacy It was discontinued in 2016
mich4s
mich4s2w ago
then what did i create from my console the top one?
Pobiega
Pobiega2w ago
Yws
mich4s
mich4s2w ago
is it with top level statements?
Pobiega
Pobiega2w ago
No, you explicitly opted for the program main instead
mich4s
mich4s2w ago
No description
mich4s
mich4s2w ago
what is this?
Pobiega
Pobiega2w ago
That's what --use-program-main does Ignore NAOT as a beginner It's an advanced thing
mich4s
mich4s2w ago
okay okay @Pobiega i have one more question though
mich4s
mich4s2w ago
No description
mich4s
mich4s2w ago
why do visual studio (left) and console (right) create a different thing inside? or just anyone who can answer, thanks
Pobiega
Pobiega2w ago
It doesn't Those are the same
mich4s
mich4s2w ago
i guess they work the same but there are some slight differences
Pobiega
Pobiega2w ago
The left just has aN explicit access modifier
mich4s
mich4s2w ago
can u talk more humanish?
Pobiega
Pobiega2w ago
But the default access for classes is internal
mich4s
mich4s2w ago
thats still too not humanish
Pobiega
Pobiega2w ago
Google C# access modifiers Or take my word for it, it's the same
mich4s
mich4s2w ago
so it doesnt matter that there is a slight difference @Pobiega
Dinosaure
Dinosaure2w 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
Pobiega2w ago
Classes are internal by default, not private
Dinosaure
Dinosaure2w ago
Thanks for the reminder, both are strictly equivalent.
Pobiega
Pobiega2w 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