Class CmdLneArgsBasic
An instance of this class efficiently processes command line switches, named arguments, and positional arguments, in such a way that they are easily accessible. The command line is completely parsed in a single pass.
Switches, named arguments, and positional arguments may be freely mixed in any way; your users aren't confined to specifying all switches and/or named arguments first, last, or in any other order.
Since command line parsing happens in the constructor, your code must define all the rules in its parameters. To that end, there are 26 constructors, which provide access to all of the rich capabilities of this object. In spite of the multitude of constructors, their organization, coupled with consistent naming and documentation of their arguments, is intended to make their features readily accessible.
While it is fairly trivial to reverse engineer the underlying Dictionary object, and read the arguments directly, the supported method of reading them is through its methods: GetArgByName, GetArgByPosition, and GetSwitchByName.
Inheritance
Namespace: WizardWrx.Core
Assembly: WizardWrx.Core.dll
Syntax
public class CmdLneArgsBasic : object
Constructors
| Improve this Doc View SourceCmdLneArgsBasic()
Initialize an instance that supports exclusively positional arguments.
Declaration
public CmdLneArgsBasic()
CmdLneArgsBasic(Dictionary<Char, String>)
Initialize the instance with a list of valid switches, each having the value specified in the corresponding item in pdctValidSwitches.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
CmdLneArgsBasic(Dictionary<Char, String>, Dictionary<String, String>)
Initialize the instance with a list of valid switches, each having the default value specified in the corresponding item in pdctValidSwitches, and a separate list of valid named arguments, defined in the same manner.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, Dictionary<string, string> pdctValidNamedArgs)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic(Dictionary<Char, String>, Dictionary<String, String>, Int32)
Initialize the instance with a list of valid switches, each having the default value specified in the corresponding item in pdctValidSwitches, and a separate list of valid named arguments, defined in the same manner.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, Dictionary<string, string> pdctValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<Char, String>, Dictionary<String, String>, CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid switches, each having the default value specified in the corresponding item in pdctValidSwitches, and a separate list of valid named arguments, defined in the same manner.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Dictionary<Char, String>, Dictionary<String, String>, CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid switches, each having the default value specified in the corresponding item in pdctValidSwitches, and a separate list of valid named arguments, defined in the same manner.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<Char, String>, Int32)
Initialize the instance with a list of valid switches, each having the value specified in the corresponding item in pdctValidSwitches.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<Char, String>, String[], Int32)
Initialize the instance with a list of valid switches, each having its default value defined by the value member of a DictionaryItem, and a separate list of valid named arguments, defined in an array of strings, with the default value supplied by the class.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, string[] pastrValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<Char, String>, String[], CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid switches, each having the default value specified in the corresponding item in pdctValidSwitches, and a separate list of valid named arguments, in an array of strings, with the class supplying a standard default.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Dictionary<Char, String>, String[], CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid switches, each having its default value defined by the value member of a DictionaryItem, and a separate list of valid named arguments, each defined as a DictionaryItem, with its default value given in the value member.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<Char, String>, CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid switches, each having the value specified in the corresponding item in pdctValidSwitches.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Dictionary<Char, String>, CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid switches, each having the value specified in the corresponding item in pdctValidSwitches.
Declaration
public CmdLneArgsBasic(Dictionary<char, string> pdctValidSwitches, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.Char, System.String> | pdctValidSwitches | Dictionary, keyed by switch name, a character, containing its desired default value, a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<String, String>)
Initialize the instance with a list of valid named arguments, each having the default value specified in the corresponding item in pdctValidNamedArgs.
Declaration
public CmdLneArgsBasic(Dictionary<string, string> pdctValidNamedArgs)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic(Dictionary<String, String>, Int32)
Initialize the instance with a list of valid named arguments, each having the default value specified in the corresponding item in pdctValidNamedArgs.
Declaration
public CmdLneArgsBasic(Dictionary<string, string> pdctValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Dictionary<String, String>, CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid named arguments, each having the default value specified in the corresponding item in pdctValidNamedArgs.
Declaration
public CmdLneArgsBasic(Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Dictionary<String, String>, CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid named arguments, each having the default value specified in the corresponding item in pdctValidNamedArgs.
Declaration
public CmdLneArgsBasic(Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[])
Initialize the instance with a list of valid switches, all having a default value of Properties.Resources.SWITCH_IS_OFF.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
CmdLneArgsBasic(Char[], Dictionary<String, String>)
Initialize the instance with a list of valid switches, each having the default value defined by the class, and a separate list of valid named arguments, each defined as a DictionaryItem, with its default value given in the value member.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, Dictionary<string, string> pdctValidNamedArgs)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic(Char[], Dictionary<String, String>, Int32)
Initialize the instance with a list of valid switches, each having the default value defined by the class, and a separate list of valid named arguments, each defined as a DictionaryItem, with its default value given in the value member.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, Dictionary<string, string> pdctValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[], Dictionary<String, String>, CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid named arguments, in a dictionary strings, where each value is the corresponding default, and a list of valid switches in an array of characters, with their default values as the class default.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Char[], Dictionary<String, String>, CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid switches, each having the default value defined by the class, and a separate list of valid named arguments, each defined as a DictionaryItem, with its default value given in the value member.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, Dictionary<string, string> pdctValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
Dictionary<System.String, System.String> | pdctValidNamedArgs | Dictionary, keyed by argument name, a string, containing its desired default value, also a string. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[], Int32)
Initialize the instance with a list of valid switches, all having a default value of Properties.Resources.SWITCH_IS_OFF.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[], String[])
Initialize the instance with lists of valid switches and named arguments.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, string[] pastrValidNamedArgs)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic(Char[], String[], Int32)
Initialize the instance with lists of valid switches and named arguments.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, string[] pastrValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[], String[], CmdLneArgsBasic.ArgMatching)
Initialize the instance with lists of valid switches and named arguments.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Char[], String[], CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with lists of valid switches and named arguments.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Char[], CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid switches, all having a default value of Properties.Resources.SWITCH_IS_OFF.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(Char[], CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid switches, all having a default value of Properties.Resources.SWITCH_IS_OFF.
Declaration
public CmdLneArgsBasic(char[] pachrValidSwitches, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | pachrValidSwitches | Array of characters, each of which is a valid (supported) switch. All switches are initialized to Properties.Resources.SWITCH_IS_OFF. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(Int32)
Initialize an instance that supports exclusively positional arguments, and enforces a user-specified limit, in lieu of a default limit of 99 positional arguments
Please see Remarks for important security considerations.
Declaration
public CmdLneArgsBasic(int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(String[])
Initialize the instance with a list of valid named arguments, each having a default value of VALUE_NOT_SET.
Declaration
public CmdLneArgsBasic(string[] pastrValidNamedArgs)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic(String[], Int32)
Initialize the instance with a list of valid named arguments, each having a default value of VALUE_NOT_SET.
Declaration
public CmdLneArgsBasic(string[] pastrValidNamedArgs, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
CmdLneArgsBasic(String[], CmdLneArgsBasic.ArgMatching)
Initialize the instance with a list of valid named arguments, each having a default value of VALUE_NOT_SET.
Declaration
public CmdLneArgsBasic(string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
CmdLneArgsBasic(String[], CmdLneArgsBasic.ArgMatching, Int32)
Initialize the instance with a list of valid named arguments, each having a default value of VALUE_NOT_SET.
Declaration
public CmdLneArgsBasic(string[] pastrValidNamedArgs, CmdLneArgsBasic.ArgMatching penmArgMatching, int pintPositionalArgCountLimit)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | pastrValidNamedArgs | Array of strings, each of which is a valid (supported) argument name. All arguments are initialized to VALUE_NOT_SET. |
CmdLneArgsBasic.ArgMatching | penmArgMatching | Use this member of the CmdLneArgs.ArgMatching enumeration to set the argument matching rules. At present, two rules are defined. See the IntelliSense documentation of any CmdLneArgs argument for details. |
System.Int32 | pintPositionalArgCountLimit | The default limit on the number of positional arguments is POSITIONAL_ARGS_COUNT_LIMIT, which is currently set to 9. Use this argument to set a lower or higher limit. A pintPositionalArgCountLimit value of less than zero is discarded silently, and the default limit remains in force. Please see Remarks for important security considerations. |
Remarks
SECURITY NOTE
All constructors in this class enforce a limit on the number of positional arguments permitted. The default limit is 9, which is defined as a public constant, POSITIONAL_ARGS_COUNT_LIMIT.
This limit is imposed to protect your program from being fed an excessively long command line, in an attempt to cause a denial of service. Although few applications require more than nine positional command line arguments, the level is made adjustable, to meet that once per career need for more than nine arguments.
While objects of this class cannot do anything about the number of characters in the command line (That is the responsibility of the Common Language Runtime.), they can, and do, limit the amount of memory allowed to be consumed to hold arguments parsed from it.
No such limits are imposed on switches and named arguments, because the number of valid arguments (hence, the upper limit on memory consumed by them) is under programmer control, and unlikely to be an issue, since invalid arguments are discarded.
WHY NINE?
I chose the number nine mostly for historical reasons. Starting with MS-DOS 1.0, the number of positional parameters supported by batch files (without resorting to tricks with SHIFT) is 9.
This limit has been carried forward into modern command processors, including CMD.EXE, the default console mode command processor of Windows NT, 2000, XP, Vista, etc.
Fields
| Improve this Doc View SourceARG_LIST_HAS_ARGS
When the ArgListIsEmpty property has this value, the command line contains at least one argument. See Remarks.
Declaration
public const bool ARG_LIST_HAS_ARGS = null
Field Value
Type | Description |
---|---|
System.Boolean |
Remarks
ArgListIsEmpty being false means only that there is an argument in the command line, which may be invalid. Check the ArgMatching array or the two invalid argument counters, InvalidNamedArgsInCmd and InvalidSwitchesInCmd.
ARG_LIST_IS_EMPTY
When the ArgListIsEmpty property has this value, the command line is empty, consisting solely of the name of the executing assembly.
Declaration
public const bool ARG_LIST_IS_EMPTY = null
Field Value
Type | Description |
---|---|
System.Boolean |
BLANK_AS_DEFAULT_ALLOWED
When the AllowEmptyStringAsDefault property has this value, an empty string is permitted as a default value. See the Remarks section of the on-line documentation of the AllowEmptyStringAsDefault property for complete details.
Declaration
public const bool BLANK_AS_DEFAULT_ALLOWED = null
Field Value
Type | Description |
---|---|
System.Boolean |
BLANK_AS_DEFAULT_FORBIDDEN
When the AllowEmptyStringAsDefault property has this value, an empty string as a default value is forbidden. See the Remarks section of the on-line documentation of the AllowEmptyStringAsDefault property for complete details.
Declaration
public const bool BLANK_AS_DEFAULT_FORBIDDEN = null
Field Value
Type | Description |
---|---|
System.Boolean |
FIRST_POSITIONAL_ARG
Use this constant with the GetArgByPosition method to get the first positional argument, or as the initializer of a For loop to get all positional arguments.
Declaration
public const int FIRST_POSITIONAL_ARG = null
Field Value
Type | Description |
---|---|
System.Int32 |
NAME_VALUE_DELIMITER
This class uses the equal sign as its delimiter between the name and value of named arguments.
Declaration
public const char NAME_VALUE_DELIMITER = null
Field Value
Type | Description |
---|---|
System.Char |
NONE
Counts are initialized to this value (zero). Making it public simplifies coding well-documented tests.
Declaration
public const int NONE = null
Field Value
Type | Description |
---|---|
System.Int32 |
POSITIONAL_ARGS_COUNT_LIMIT
This constant defines the default number of positional arguments that instances of this class will capture.
Declaration
public const int POSITIONAL_ARGS_COUNT_LIMIT = null
Field Value
Type | Description |
---|---|
System.Int32 |
VALUE_NOT_SET
This symbolic constant maps to the empty string, and indicates that a specified named or positional argument was omitted from the command line.
Declaration
public const string VALUE_NOT_SET = null
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceAllowEmptyStringAsDefault
The value of this property determines how the GetArgDefaultToUse and GetSwitchDefaultToUse methods treat an empty string supplied as a default value to return. See Remarks for complete details.
Declaration
public bool AllowEmptyStringAsDefault { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The AllowEmptyStringAsDefault property is initialized to FALSE, to maintain backwards compatibility with previous versions of the library that exports this class.
By default switches return a string value of "OFF" to indicate their omission from the command line. To override this behavior, you must call the two-argument overload of GetSwitchDefaultToUse, specifying a default string value as the second argument.
Prior to version 2.0, this overload treated both null references (Nothing in Visual Basic) and empty strings equally, returning the class default value of "OFF" in both cases.
Beginning with version 2.0, this behavior can be overridden in one of two ways.
Setting the AllowEmptyStringAsDefault property to TRUE (signified by symbolic constant BLANK_AS_DEFAULT_ALLOWED) changes the behavior for the entire class for the rest of its lifetime, or until it is set back to its default, whichever comes first.
Calling method GetSwitchDefaultToUse or GetArgDefaultToUse with a third (Boolean) argument that affects only the behavior of that one call, regardless of the current AllowEmptyStringAsDefault setting. This method leaves the AllowEmptyStringAsDefault property unchanged.
ArgListIsEmpty
This property returns True (ARG_LIST_IS_EMPTY) when the command line is devoid of arguments.
Otherwise, it returns False (ARG_LIST_HAS_ARGS), indicating that the command line contains at least one argument. See Remarks.
Declaration
public bool ArgListIsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
ArgListIsEmpty being false means only that there is an argument in the command line, which may be invalid. Check the ArgMatching array or the two invalid argument counters, InvalidNamedArgsInCmd and InvalidSwitchesInCmd.
ArgumentMatching
Although you cannot change the rules in the middle of the game, transparency is highly desirable.
Declaration
public CmdLneArgsBasic.ArgMatching ArgumentMatching { get; }
Property Value
Type | Description |
---|---|
CmdLneArgsBasic.ArgMatching |
ArgumentTypeArray
This property is an array of ArgType enumerated types, which has one element for each command line argument. Use this list to find and report invalid command line arguments, if any.
Declaration
public CmdLneArgsBasic.ArgType[] ArgumentTypeArray { get; }
Property Value
Type | Description |
---|---|
CmdLneArgsBasic.ArgType[] |
Count
Get the total number of valid arguments of all types.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
DefinedNamedArgs
Get the count of named arguments defined by the constructor.
Declaration
public int DefinedNamedArgs { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
DefinedSwitches
Count of switches defined by the constructor
Declaration
public int DefinedSwitches { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
InvalidArgsCount
Total number of invalid arguments found in the command line. This is the sum of InvalidNamedArgsInCmd and InvalidSwitchesInCmd. Use it as a quick check for invalid arguments.
Declaration
public int InvalidArgsCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
InvalidNamedArgsInCmd
Count of invalid named arguments found in the command line.
Declaration
public int InvalidNamedArgsInCmd { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
InvalidSwitchesInCmd
Count of invalid switches found in the command line.
Declaration
public int InvalidSwitchesInCmd { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
PositionalArgsInCmdLine
Count of positional arguments found in the command line.
Declaration
public int PositionalArgsInCmdLine { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
SWITCH_IS_OFF
Gets the SWITCH_IS_OFF string, which is loaded from the string resources of the DLL into a private static read-only string.
Declaration
public static string SWITCH_IS_OFF { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This static read-only property replaces a like named constant, which I moved into the resource strings because that is really where it belongs, so that the library can be adapted for another language by substituting a localized string resource.
While the simplest approach would be to assign these names to the private strings, and mark them public, doing so would obscure their their true nature.
SWITCH_IS_ON
Gets the SWITCH_IS_ON string, which is loaded from the string resources of the DLL into a private static read-only string.
Declaration
public static string SWITCH_IS_ON { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This static read-only property replaces a like named constant, which I moved into the resource strings because that is really where it belongs, so that the library can be adapted for another language by substituting a localized string resource.
While the simplest approach would be to assign these names to the private strings, and mark them public, doing so would obscure their their true nature.
ValidNamedArgsInCmdLine
Count of valid named arguments found in the command line.
Declaration
public int ValidNamedArgsInCmdLine { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ValidSwitchesInCmdLine
Count of valid switches found in the command line.
Declaration
public int ValidSwitchesInCmdLine { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceArgNameFromKeyValue(String)
Extract the argument name from a string that consists of the key (index) of the collection.
Declaration
public static string ArgNameFromKeyValue(string pstrArgKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgKey | Specify the key to parse and strip, so that it can be fed into an instance method to retrieve the value of a named argument or switch. |
Returns
Type | Description |
---|---|
System.String | If the function succeeds, the return value is the name of a named argument or of a switch, which can be fed into GetArgByName, GetSwitchByName, or one of their siblings. |
Remarks
Since this class derives from a Dictionary whose keys and values are strings, given the string that becomes the pstrArgKey argument of this method, you could just as easily get the value directly. However, if you did so, you would lose the benefit of default value assignment, not to mention the accessors that bundle conversions to Integer, Boolean, and Character types. Moreover, reaching into the base class makes it slightly less obvious that the value retrieved is that of a command line argument, let alone its name and intrinsic type (switch versus named argument versus positional argument).
A wiser design would hide the dictionary from view. Notwithstanding this one-off use, it is not too late to do so, since this is the only case in which I have reached into the base class in this way.
FirstCharFromString(String)
Extract the first character from a string, and return it as a char value type.
Declaration
public static char FirstCharFromString(string pstrIn)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrIn | The first character in this string is returned. |
Returns
Type | Description |
---|---|
System.Char | The return value is the first character of string pstrIn, as a scalar value type. |
FirstCharFromString(String, Char)
Extract the first character from a string, and return it as a char value type.
Declaration
public static char FirstCharFromString(string pstrIn, char pchrDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrIn | The first character in this string is returned. |
System.Char | pchrDefault | If string pstrIn is null or empty, this character is returned. |
Returns
Type | Description |
---|---|
System.Char | The return value is the first character of string pstrIn, as a scalar value type. |
GetArgByMultipleAliases(String[])
Return the value of an argument that has two or more aliases.
Declaration
public string GetArgByMultipleAliases(string[] pastrValiddArgNames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | pastrValiddArgNames | This is an array of strings, each of which is the name of a command line argument that is a synonym. See Remarks. |
Returns
Type | Description |
---|---|
System.String | The return value is the specified value, or its default value, of none of the synonyms appears in the input. See Remarks. |
Remarks
Arguments are evaluated in the order specified in pastrValiddArgNames, Synonyms are assumed to return the same default value.
GetArgByName(String)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public string GetArgByName(string pstrArgName)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
Returns
Type | Description |
---|---|
System.String | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pstrDefault is returned. |
Remarks
This overload is a wrapper around the second overload, GetArgByName ( int, string ), which does the real work. This method calls it internally, passing a default value of VALUE_NOT_SET.
GetArgByName(String, String)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public string GetArgByName(string pstrArgName, string pstrDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.String | pstrDefault | Specify a default value to return if the argument was omitted from the command line, or VALUE_NOT_SET or a null reference (Nothing in Visual Basic), to use an empty string as the default. |
Returns
Type | Description |
---|---|
System.String | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pstrDefault is returned. |
Remarks
POTENTIAL BREAKING CHANGE:
When the AllowEmptyStringAsDefault property is FALSE and argument pstrDefault is a null reference, this method returns the null reference. Previous versions returned the empty string anyway, which wasn't the intended behavior, and a missing command line argument thereby escaped detection.
Hence, going forward, when pstrDefault is NULL, you must be prepared to handle a null reference as the return value.
GetArgByName(String, String, Boolean)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public string GetArgByName(string pstrArgName, string pstrDefault, bool pfAllowEmptyStringAsDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.String | pstrDefault | Specify a default value to return if the argument was omitted from the command line, or VALUE_NOT_SET or a null reference (Nothing in Visual Basic), to use an empty string as the default. |
System.Boolean | pfAllowEmptyStringAsDefault | Set this to TRUE if you want an empty string for the value of the pstrDefault argument treated as a valid default value. Otherwise, empty strings are treated as null references (Nothing in Visual Basic). |
Returns
Type | Description |
---|---|
System.String | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pstrDefault is returned. |
Remarks
POTENTIAL BREAKING CHANGE:
When the AllowEmptyStringAsDefault property is FALSE and argument pstrDefault is a null reference, this method returns the null reference. Previous versions returned the empty string anyway, which wasn't the intended behavior, and a missing command line argument thereby escaped detection.
Hence, going forward, when pstrDefault is NULL, you must be prepared to handle a null reference as the return value.
GetArgByNameAsChar(String)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public char GetArgByNameAsChar(string pstrArgName)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
Returns
Type | Description |
---|---|
System.Char | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pchrDefault is returned. |
Remarks
This method returns through GetArgByName, by way of FirstCharFromString. Hence, everything that applies to either of them applies as well to this method.
GetArgByNameAsChar(String, Char)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public char GetArgByNameAsChar(string pstrArgName, char pchrDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Char | pchrDefault | Specify a default value to return if the argument was omitted from the command line, or VALUE_NOT_SET or a null reference (Nothing in Visual Basic), to use a null character as the default. |
Returns
Type | Description |
---|---|
System.Char | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pchrDefault is returned. |
Remarks
This method returns through GetArgByName, by way of FirstCharFromString. Hence, everything that applies to either of them applies as well to this method.
GetArgByNameAsChar(String, Char, Boolean)
Given the external name of a named argument (the name that was supplied to the constructor), return its value, which is either the value given on the command line or the default specified in this method call.
Declaration
public char GetArgByNameAsChar(string pstrArgName, char pchrDefault, bool pfAllowEmptyStringAsDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Char | pchrDefault | Specify a default value to return if the argument was omitted from the command line, or VALUE_NOT_SET or a null reference (Nothing in Visual Basic), to use a null character as the default. |
System.Boolean | pfAllowEmptyStringAsDefault | Set this to TRUE if you want an empty string for the value of the pstrDefault argument treated as a valid default value. Otherwise, empty strings are treated as null references (Nothing in Visual Basic). |
Returns
Type | Description |
---|---|
System.Char | If the requested name is valid, and the argument was entered on the command line, the value supplied on the command line is returned. If the argument was omitted from the command line, or if the specified name is invalid, the value specified in argument pchrDefault is returned. |
Remarks
This method returns through GetArgByName, by way of FirstCharFromString. Hence, everything that applies to either of them applies as well to this method.
GetArgByNameAsInt(String)
If the value of a switch is an integer, return it. Otherwise, return zero.
Declaration
public int GetArgByNameAsInt(string pstrArgName)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetArgByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetArgByNameAsInt(String, Int32)
If the value of a switch is an integer, return it. Otherwise, return pintDefault.
Declaration
public int GetArgByNameAsInt(string pstrArgName, int pintDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Int32 | pintDefault | Specify a default value to return if the argument was omitted from the command line. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetArgByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetArgByNameAsInt(String, Int32, Boolean)
If the value of a switch is an integer, return it. Otherwise, return pintDefault.
Declaration
public int GetArgByNameAsInt(string pstrArgName, int pintDefault, bool pfAllowEmptyStringAsDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | pstrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Int32 | pintDefault | Specify a default value to return if the argument was omitted from the command line. |
System.Boolean | pfAllowEmptyStringAsDefault | Set this to TRUE if you want an empty string for the value of the pstrDefault argument treated as a valid default value. Otherwise, empty strings are treated as null references (Nothing in Visual Basic). |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetArgByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetArgByPosition(Int32)
Get a positional argument by its ordinal position.
Declaration
public string GetArgByPosition(int pintIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintIndex | Position of argument in list. Arguments are numbered from 1. |
Returns
Type | Description |
---|---|
System.String | The argument value at the ordinal position specified by pintIndex is returned, unless pintIndex is out of range, in which case an empty string is returned. |
Remarks
This overload is a wrapper around the second overload, GetArgByPosition ( int, string ), which does the real work. This method calls it internally, passing a default value of VALUE_NOT_SET.
GetArgByPosition(Int32, String)
Get a positional argument by its ordinal position.
Declaration
public string GetArgByPosition(int pintIndex, string pstrDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintIndex | Position of argument in list. Arguments are numbered from 1. |
System.String | pstrDefault | Default value to return if argument ordinal is greater than the number of positional arguments entered on the command line. |
Returns
Type | Description |
---|---|
System.String | The argument value at the ordinal position specified by pintIndex is returned, unless pintIndex is out of range, in which case, the default value specified in pstrDefault is returned. |
Remarks
POTENTIAL BREAKING CHANGE:
When the AllowEmptyStringAsDefault property is FALSE and argument pstrDefault is a null reference, this method returns the null reference. Previous versions returned the empty string anyway, which wasn't the intended behavior, and a missing command line argument thereby escaped detection.
Hence, going forward, when pstrDefault is NULL, you must be prepared to handle a null reference as the return value.
GetArgByPositionAsInt(Int32)
If the value of a switch is an integer, return it. Otherwise, return zero.
Declaration
public int GetArgByPositionAsInt(int pintIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintIndex | Position of argument in list. Arguments are numbered from 1. the constructor. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetArgByPosition to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetArgByPositionAsInt(Int32, Int32)
If the value of a switch is an integer, return it. Otherwise, return pintDefault.
Declaration
public int GetArgByPositionAsInt(int pintIndex, int pintDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintIndex | Position of argument in list. Arguments are numbered from 1. the constructor. |
System.Int32 | pintDefault | Specify a default value to return if the argument was omitted from the command line. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetArgByPosition to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetBooleanSwitchByName(Char)
Test for the presence of a defined switch. The modifier, if any, is ignored.
Declaration
public bool GetBooleanSwitchByName(char pchrName)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrName | Character to identify switch. This must be one of the characters stored in the array, or used as keys in the dictionary passed into the instance constructor. |
Returns
Type | Description |
---|---|
System.Boolean | The return value is TRUE if the switch is present, with or without a modifier (which is ignored). Otherwise, the return value is FALSE. |
GetSwitchByName(Char)
Return the value stored for a switch argument.
Declaration
public string GetSwitchByName(char pchrName)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrName | Character to identify switch. This must be one of the characters stored in the array, or used as keys in the dictionary passed into the instance constructor. |
Returns
Type | Description |
---|---|
System.String | If the switch was defined in the constructor, and it was specified on the command line of the executing assembly, the value defined on the command line is returned. Otherwise, the default value, if any, passed into the constructor is returned. Failing both of those, the generic default value constant, Properties.Resources.SWITCH_IS_OFF, is returned. |
Remarks
This overload is a wrapper around the other overload, GetSwitchByName ( char, string ), which does the real work. This method calls it internally, passing a default value of Properties.Resources.SWITCH_IS_OFF.
GetSwitchByName(Char, String)
Return the value stored for a switch argument.
Declaration
public string GetSwitchByName(char pchrName, string pstrDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrName | Character to identify switch. This must be one of the characters stored in the array, or used as keys in the dictionary passed into the instance constructor. |
System.String | pstrDefault | Default value to return if argument pchrName is not in the list of valid switches passed into the constructor. See pchrName. |
Returns
Type | Description |
---|---|
System.String | If the switch was defined in the constructor, and it was specified on the command line of the executing assembly, the value defined on the command line is returned. Otherwise, the default value, if any, passed into the constructor is returned. Failing both of those, the generic default value constant, Properties.Resources.SWITCH_IS_OFF, is returned. |
Remarks
POTENTIAL BREAKING CHANGE:
When the AllowEmptyStringAsDefault property is FALSE and argument pstrDefault is a null reference, this method returns the null reference. Previous versions returned the empty string anyway, which wasn't the intended behavior, and a missing command line argument thereby escaped detection.
Hence, going forward, when pstrDefault is NULL, you must be prepared to handle a null reference as the return value.
GetSwitchByName(Char, String, Boolean)
Return the value stored for a switch argument.
Declaration
public string GetSwitchByName(char pchrName, string pstrDefault, bool pfAllowEmptyStringAsDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrName | Character to identify switch. This must be one of the characters stored in the array, or used as keys in the dictionary passed into the instance constructor. |
System.String | pstrDefault | Default value to return if argument pchrName is not in the list of valid switches passed into the constructor. See pchrName. |
System.Boolean | pfAllowEmptyStringAsDefault | Set this to TRUE if you want an empty string for the value of the pstrDefault argument treated as a valid default value. Otherwise, empty strings are treated as null references (Nothing in Visual Basic). |
Returns
Type | Description |
---|---|
System.String | If the switch was defined in the constructor, and it was specified on the command line of the executing assembly, the value defined on the command line is returned. Otherwise, the default value, if any, passed into the constructor is returned. Failing both of those, the generic default value constant, Properties.Resources.SWITCH_IS_OFF, is returned. |
GetSwitchByNameAsInt(Char)
If the value of a switch is an integer, return it. Otherwise, return zero.
Declaration
public int GetSwitchByNameAsInt(char pchrArgName)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrArgName | Specify the external name of the argument, as it was identified to the constructor. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetSwitchByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetSwitchByNameAsInt(Char, Int32)
If the value of a switch is an integer, return it. Otherwise, return pintDefault.
Declaration
public int GetSwitchByNameAsInt(char pchrArgName, int pintDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Int32 | pintDefault | Specify a default value to return if the argument was omitted from the command line. |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetSwitchByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |
GetSwitchByNameAsInt(Char, Int32, Boolean)
If the value of a switch is an integer, return it. Otherwise, return pintDefault.
Declaration
public int GetSwitchByNameAsInt(char pchrArgName, int pintDefault, bool pfAllowEmptyStringAsDefault)
Parameters
Type | Name | Description |
---|---|---|
System.Char | pchrArgName | Specify the external name of the argument, as it was identified to the constructor. |
System.Int32 | pintDefault | Specify a default value to return if the argument was omitted from the command line. |
System.Boolean | pfAllowEmptyStringAsDefault | Set this to TRUE if you want an empty string for the value of the pstrDefault argument treated as a valid default value. Otherwise, empty strings are treated as null references (Nothing in Visual Basic). |
Returns
Type | Description |
---|---|
System.Int32 | This method passes the value returned by GetSwitchByName to the int.TryParse method. Hence, everything that applies to either of them applies as well to this method. |