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