I\'m using the following right now:
foreach (string file in files) {
switch (filetype.Value) {
case \"ReadFile\":
ReadFile(file);
You can use a delegate:
Action action;
switch (filetype.Value) {
case "ReadFile":
action = ReadFile;
break;
case "ReadMSOfficeWordFile":
action = ReadMSOfficeWordFile;
break;
case "ReadMSOfficeExcelFile":
action = ReadMSOfficeExcelFile;
break;
case "ReadPDFFile":
action = ReadPDFFile;
break;
default:
throw new NotImplementedException("Unhandled file type '"+filetype.Value+"'.");
}
foreach (string file in files) {
action(file);
}