PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 21, 2022

[FIXED] How to access command line arguments with new Console App template in VS2022

 November 21, 2022     c#, visual-studio     No comments   

Issue

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?


Solution

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):

No args shown in IntelliSense

args causes compile error


However, couple of lines later:

args appear

Voila!



Answered By - Bozhidar Stoyneff
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing