The variable LocalGroups
is a Dictionary<string, string>
.
You cannot simply write that to your TextWriter
. When you try, you get the type of object, which is what you're seeing.
Dictionary<string, string> LocalGroups = new Dictionary<string, string>();
...
...
tw.WriteLine(LocalGroups); // writes System.Collections.Generic.Dictionary`2...
Instead, you can iterate through the collection and write each key/value pair:
foreach (var group in LocalGroups)
tw.WriteLine("Key: {0} Value: {1}", group.Key, group.Value);