Split string containing command-line parameters into string[] in C#
It annoys me that there’s no function to split a string based on a function that examines each character. If there was, you could write it like this: public static IEnumerable<string> SplitCommandLine(string commandLine) { bool inQuotes = false; return commandLine.Split(c => { if (c == ‘\”‘) inQuotes = !inQuotes; return !inQuotes && c == ‘ … Read more