I inherit the service on several console applications, which are introduced naturally with static void Main(string[] args). However, the code ignores the array argsand instead reads the command line options from System.Environment.CommandLine.
Is there a functional difference?
The content looks identical. In any case, I would suspect a momentary performance hit by triggering System.Environment.CommandLine(but not so much that I was ever worried or careful enough to measure).
UPDATE: I suspected it System.Environment.CommandLineshould contain an executable path, but I did not see it ... because I was looking for the wrong place. The ALSO code has string[] arrCmdLine = System.Environment.GetCommandLineArgs();.... System.Environment.CommandLine.ToLower()checked for the presence of "debug", while all other parameters are extracted from GetCommandLineArgs(), and I mentally merged the two while I walked "why not just use it args[]?"
For many years, I was tormented by a better way to parse command line arguments, when it all was "putting them in the correct order!". [Jk]
source
share