I've written some code to output any IEnumerable
collection to a file, but can't pass dictionaries to it. I'm now trying to convert the dictionary (which might be int
, int
or int
, string
or any other combination) into an array so I can do this. The code below indicates an error when I try to pass it to the method requiring the IEnumerable
.
Generics are something I haven't done much with so perhaps I've done something wrong with those.
public static bool DictionaryToFile<T, U>(Dictionary<T, U> TheDictionary, string FilePath)
{
long count = 0;
string[,] myArray = new string[2,TheDictionary.Count];
foreach (var current in TheDictionary)
{
myArray[0, count] = current.Key.ToString();
myArray[1, count] = current.Value.ToString();
}
// error appears here
TypedListToFile<string[,]>(myArray, FilePath);
return true;
}
The other one I'm calling:
public static bool TypedListToFile<T>(IEnumerable<T> TypedList, string FilePath)