C
C#9mo ago
Pesar

❔ Disabling Top level statements in VSCode

Anyone know how I can disable top level statemnts in VSCode? I hate the top level statements
No description
38 Replies
Angius
Angius9mo ago
Just write the boilerplate if you like useless code this much
Thinker
Thinker9mo ago
You can just write a Program class and Main method and it'll work
Pesar
Pesar9mo ago
the what no well I should rephrase I hate the top level statements since I learnt with the old code type Idk how to use the new tls
Angius
Angius9mo ago
Boilerplate, useless code in other words Just write class Program Add a void Main() to it Boom
Pesar
Pesar9mo ago
ty how exactly do you use tls like how do ymou make new methods
Angius
Angius9mo ago
You just... do?
Mayor McCheese
Mayor McCheese9mo ago
just pretend you're in the main method
Pesar
Pesar9mo ago
qwhat if I dont wanna be 😭 calling other methods or do you not have to do that in tls
Angius
Angius9mo ago
Then you write a method right there At the end of the file And call it Or you make a new file with a class and a method And use that
Mayor McCheese
Mayor McCheese9mo ago
public static void Main(string[] args) { // TLS is right here. }
Pesar
Pesar9mo ago
Like this?
Pesar
Pesar9mo ago
So
No description
Angius
Angius9mo ago
Yeah
Pesar
Pesar9mo ago
I frogot how to request stuff or whatever in methods so uh
Angius
Angius9mo ago
Well, you'll need to type your parameters Or... give them a name Whichever it is that you didn't do But yes
Pesar
Pesar9mo ago
I didnt do 10 what did I do skul
Pesar
Pesar9mo ago
How do i give maaaa the name string
No description
Angius
Angius9mo ago
MethodName(type name, type name, type name)
Pesar
Pesar9mo ago
oh my god sorry and thanks
Angius
Angius9mo ago
For example,
static int Sum(int first, int second)
{
return first + second;
}
static int Sum(int first, int second)
{
return first + second;
}
Pesar
Pesar9mo ago
tyty wait so you're not supposed to leave the main method?
Pesar
Pesar9mo ago
No description
Pesar
Pesar9mo ago
OR
Pesar
Pesar9mo ago
No description
Mayor McCheese
Mayor McCheese9mo ago
there are some magic in TLS that make things essentially end up like your first image you're sorta overthinking top level statements was my point.
Pesar
Pesar9mo ago
i indeed am hm ty
Angius
Angius9mo ago
This is basically what the compiler does with top-level statements
No description
Thinker
Thinker9mo ago
that's a good gif
Mayor McCheese
Mayor McCheese9mo ago
compilers can do blinkys?
Pesar
Pesar9mo ago
so SDK5 people are the compilers
Angius
Angius9mo ago
SDK5...?
No description
Pesar
Pesar9mo ago
.net sdk 5 And that
Angius
Angius9mo ago
Uh, well, .NET 5 SDk does contain the compiler, yes Since C# is a compiled language... it does need a compiler I'm not sure if any of the people working on it are a compiler gained sentience, but I'd doubt that
Jimmacle
Jimmacle9mo ago
you never know
Thinker
Thinker9mo ago
Roslyn is indeed sentient
Mayor McCheese
Mayor McCheese9mo ago
chat gproslyn
Thinker
Thinker9mo ago
Fred and everyone else in #roslyn is just a figment of Roslyn
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.