c# - Key value pair as a param in a console app -
is there easy way allow collection of key/value pairs (both strings) command line parameters console app? if mean having commandline looking this: c:> yourprogram.exe /switch1:value1 /switch2:value2 ... this can parsed on startup looking this: private static void main(string[] args) { regex cmdregex = new regex(@"/(?<name>.+?):(?<val>.+)"); dictionary<string, string> cmdargs = new dictionary<string, string>(); foreach (string s in args) { match m = cmdregex.match(s); if (m.success) { cmdargs.add(m.groups[1].value, m.groups[2].value); } } } you can lookups in cmdargs dictionary. not sure if that's want though. //daniel