I have created a method which gives different message box output results depending on the passed command line arguments.
Currently I have to start debugging every time I want to change the command line arguments string.
Is there a way to change the command line arguments during a debugging session?
EDIT: I've added some sample code
private static class MyParsers
{
public static List<string> args;
static MyParsers()
{
args = Environment.GetCommandLineArgs().ToList();
}
public static List<string> ParseOptions()
{
return ParseOptions(true);
}
public static List<string> ParseOptions(bool caseSensitive)
{
return caseSensitive
? args
: args.MyExtToLower();
}
public static bool OptionExists(string option)
{
return OptionExists(option, true);
}
public static bool OptionExists(string option, bool caseSensitive)
{
return caseSensitive
? ParseOptions().Contains(option)
: ParseOptions().MyExtToLower().Contains(option);
}
public static bool OptionExists(string option, string delimiter)
{
return OptionExists(option, false, delimiter);
}
public static bool OptionExists(string option, bool caseSensitive, string delimiter)
{
var args = ParseOptions(caseSensitive);
for (var i = 1; i < args.Count; i++)
{
if (args[i].Contains(option + delimiter)) return true;
}
return false;
}
}
Then I call MessageBox.Show(MyParsers.OptionExists("/list","=").ToString());
If the command line argument is /list=blah it returns true.
If the command line argument is /listary it returns false.
What method would you suggest for quickly altering the command line parameters? considering the above code I am using.
mainthen how are you using them for anything? What are you actually trying to accomplish, because it sure sounds like you have the wrong approach... If you add some code to your question we can almost certainly point you in a better direction.