I am working with an input file that has a list of guild names and then guild servers for those guild names. My problem is that for some guilds there is a duplicate, meaning that the same guild exists on different servers. So I need the guildName, read from my input file, to display the different server it is on. Here is the code I have so far:
private void buildGuilds()
{
using (StreamReader inFile = new StreamReader("guilds.txt"))
{
string str = null;
char[] delimiters = {'-', '\t'};
//while the buffer isn't empty
while ((str = inFile.ReadLine()) != null)
{
SortedList<string, string> guild = new SortedList<string, string>();
string[] Buffer = str.Split(delimiters);
guildName = Buffer[1];
guildServer = Buffer[2];
if (!dictGuilds.ContainsKey(guildName))
{
dictGuilds.Add(guildName, new List<string>());
}
dictGuilds[guildName].Add(guildServer);
So my program reads the data into 2 variables and then determines what values go where but I cannot get it to print when using the conventional foreach pair.Key pair.Value method. Here is my print method as well.
private void printGuilds()
{
foreach (KeyValuePair<string, List<string>> pair in dictGuilds)
{
Guilds_List.Items.Add(pair.Key + pair.Value);
}
}
any help i could get would be great. Thank you so much