I use Visual Studio Code and code in C#. I'm using the extension: C# Dev Kit.
But the default code that should always be visible is not shown, how do I get it to show? Do this feature have a name that hide this "default code" ?
The missing code?
using System;
namespace GettingInput
{
class Program
{
static void Main()
{
// Code
}
}
}
I use Visual Studio Code and code in C#. I'm using the extension: C# Dev Kit.
But the default code that should always be visible is not shown, how do I get it to show? Do this feature have a name that hide this "default code" ?
The missing code?
using System;
namespace GettingInput
{
class Program
{
static void Main()
{
// Code
}
}
}
Share
Improve this question
edited Feb 8 at 9:46
DanneManne
asked Feb 8 at 9:41
DanneManneDanneManne
376 bronze badges
3
|
2 Answers
Reset to default 1The feature is called "top-level statements" as @MoonMist suggested in the comments. Read more about it here. There's no missing code; the compiler is simply providing it for you (note the comment in the docs that the method is not called main
and is not accessible).
If you want to use the older main
method, just paste your existing top-level statement into the code you've written above. No project changes are required; it will simply be detected and used instead.
Note though that top-level statements can do all the things that a main
method could, like access args
or return exit codes.
Or right click on the code, and choose Refactor, followed by "Convert to 'Program.Main' style program:
--use-program-main
option when you generate your project. – OldBoy Commented Feb 8 at 9:52