
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
168
|
Chapter 3: Classes and Structures
Discussion
Before command-line parameters can be parsed, a common format must first be
decided upon. The format for this recipe follows the command-line format for the
Visual C# .NET language compiler. The format used is defined as follows:
• All command-line arguments are separated by one or more whitespace
characters.
• Each argument may start with either a - or / character, but not both. If it does
not, that argument is considered a literal, such as a filename.
• Each argument that starts with either the - or / character may be divided up into
a switch followed by a colon followed by one or more arguments separated with
the ; character. The command-line parameter
-sw:arg1;arg2;arg3 is divided up
into a switch (
sw) and three arguments (arg1, arg2, and arg3). Note that there
should not be any spaces in the full argument; otherwise, the runtime command-
line parser will split up the argument into two or more arguments.
{
DisplayErrorMsg("");
}
public virtual void DisplayErrorMsg(string msg)
{
Console.WriteLine
("An error occurred while processing the command-line arguments:");
Console.WriteLine(msg);
Console.WriteLine( );
FileVersionInfo version =
Process.GetCurrentProcess( ).MainModule.FileVersionInfo;
if (Process.GetCurrentProcess( ).ProcessName.Trim( ...