I\'m using the following right now:
foreach (string file in files) {
switch (filetype.Value) {
case \"ReadFile\":
ReadFile(file);
I believe what you're looking for will need some refactoring of your code.
All of your "cases" (TextFile, MSOfficeWordFile, MSOfficeExcelFile, PdfFile) should be their own classes which implement a single interface.
Your interface should be named something like "IReadableFile" and specify a method named "ReadFile()".
Each class should have their own implementation of "ReadFile()"
Example:
public interface IReadableFile
{
void ReadFile();
}
public class MSOfficeWordFile : IReadableFile
{
public void ReadFile()
{
ReadMSOfficeWordFile(file);
}
}
foreach(IReadableFile file in files)
file.ReadFile();
Code may contain some mistakes, but I hope you get the idea.