This is how it's done in our console app:
using System.Linq;
namespace Generator
{
internal class Program
{
public static void Main(string[] args)
{
var param1 = args.SingleOrDefault(arg => arg.StartsWith("p1:"));
if (!string.IsNullOrEmpty(param1))
{
param1 = param1.Replace("p1:", "");
}
//...
}
}
}
It's supposed to be called like this: Generator.exe p1:somevalue
Can you think of a better/simpler way of parsing arguments?