Created
February 21, 2017 08:36
-
-
Save manifoldhiker/2a5a4a35dc7f2d8368653c9a4dc7ade0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void loadDictionary() | |
{ | |
try | |
{ | |
dictionary = new Dictionary<string, List<string>>(); // **field to hold your data. Could be List<> or somethin | |
using (StreamReader sr = new StreamReader("E:\\Programming\\answer_database.txt")) // **Opening file, create reader | |
{ | |
//**in my dictionary words were separated by "\" | |
string[] arr = sr.ReadLine().Split('\\'); // **read first line | |
while (arr.Length != 0) // **while we have smth to read | |
{ | |
arr = sr.ReadLine().Split('\\'); //**read next line (first was misfourtunantly skipped =( ) | |
//**LOGIK GOES HERE | |
if (dictionary.ContainsKey(arr[0])) | |
{ | |
dictionary[arr[0]].Add(arr[1]); | |
continue; | |
} | |
dictionary.Add(arr[0], new List<string>() { arr[1] }); | |
//** | |
} | |
} | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Loaded"); | |
} | |
Console.WriteLine("Loaded"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment