Using the C# dev kit(not the dotnet cli) how to disable top level statements within vscode?
Is there a setting to disable top level statements in vscode please?. I only know the "dotnet new console --use-program-main" command
19 Replies
what do you mean disable them? just don't use them
think he wants the opposite the older template
with namespace and class
which vscode doesnt really have an option for other than doing the cli command manually
like in visual studio u have a checkbox to disable/enable it
exactly....i was hoping there is a way in vscode too
only way I can think of would be for u to edit the default template
How can i do that please?
mmm I dont know where .net 8 stores the template I know where visual studio does and I dont know if its shared or the same folder
https://learn.microsoft.com/en-us/visualstudio/ide/how-to-locate-and-organize-project-and-item-templates?view=vs-2022
that is for visual studio dont know if its shared with dotnet or not so I dont know what would be the location to find the ones used by the cli and how easy they can be editted
i see...thank you anyway my friend...i appreciate your help
The alternative is to just use top-level statements ¯\_(ツ)_/¯
ah looks like the templates on dotnet 8 are nuget packages now interesting
so u would have to package it properly to replace it so I would not recommend u to touch those
anyway gl with whatever u decide to do
C:\Program Files\dotnet\templates\x.x.x is the folder
Templates in general are distributed as nuggies
before it was not(been a few years since I done it, I remember just modifying a file and that was it but with .net core which is now just .net seems like a lot has changed in that regards)
u could easily modify it on older version of visual studio
I am a beginner to c# and i thought that it is better to start with the old style first.Most tutorials follow the old style. I guess i have to stick withe the new template
if you're a beginner I strongly recommend u use visual studio if u are not on linux
c# is not like python and other alike languages and visual studio will give u a better frame while i learn it
i am on linux
Do you qualify for $freerider license?
There are two ways to get Rider for free:
Being a student: https://www.jetbrains.com/community/education/#students
Using it for an OSS project: https://www.jetbrains.com/community/opensource/#support
you can just press Ctrl + . in your Program.cs and then select the option "Convert to Main style program"
it is not the same as changing the template yes but it is one press to go back to the old style
Thank you really...I did not know that