How to write the content of a dictionary to a text file?
- by codemonkie
I have a dictionary object of type Dictionary
and trying to use StreamWriter to output the entire content to a text file but failed to find the correct method from the Dictionary class.
using (StreamWriter sw = new StreamWriter("myfile.txt"))
{
sw.WriteLine(dictionary.First());
}
I can only retrieve the first…