I have a block of C# that looks like this
public static string[,] FileTypesDict = new string[,] {
{"txt", "ReadFile"},
{"doc", "ReadMSOfficeWordFile"},
{"docx", "ReadMSOfficeWordFile"},
{"xls", "ReadMSOfficeExcelFile"},
{"xlsx", "ReadMSOfficeExcelFile"},
{"pdf", "ReadPDFFile"},
};
I would like to use this inside another function like this...
static void FindFiles() {
foreach (string type[] in FileTypesDict) {
// Find all files with extension
string[] files = Directory.GetFiles(FilePath, type[0]);
// To be used in another fun way, the longer description
string filetype = type[1]
}
}
That, of course, doesn't work... It seems to only work when I do this -->
static void FindFiles() {
foreach (string type in FileTypesDict) {
Console.WriteLine(type);
}
}
That will print each part of each array, like this -->
txt
ReadFile
doc
ReadMSOfficeWordFile
docx
ReadMSOfficeWordFile
xls
ReadMSOfficeExcelFile
xlsx
ReadMSOfficeExcelFile
pdf
ReadPDFFile
I'd basically like to look over the array of arrays and use each array inside of the loop...
Dictionary<string,string>?foreach (string[] type in FileTypesDict)- does that fix it?