Reputation: 3634
I wonder how one can access the command line arguments, given this is all that gets generated in the Program.cs
file by the new template for Console Application in Visual Studio 2022:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Moreover, there is no args
variable in scope.
So how to access CLI arguments?
Upvotes: 6
Views: 6096
Reputation: 10729
I prefer the old style and check the "Do not use top-level statements
" while creating the project:
This way you'd have the good old main with the explicit arguments. You can also possibly add the scaffolding after the fact.
Upvotes: 2
Reputation: 3634
Apparently one needs to add some code to fireup the IntelliSense. I.e., if you try to access args
as a first thing in your program you'll be supprised (like myself):
However, couple of lines later:
Voila!
Upvotes: 8