Create Dictionary from Existing Text File

I am trying to write a program that will read a text file then creates a dictionary that places each of the words into a key and then the line in which it appears to its value. After this, the next step is to create a new text file which compiles the dictionary into alphabetical order and places which line(s) the word is in. So far all of the coding I have done is here, but I am stuck and have no idea how to progress. Any ideas?

            StreamReader inputFile;
            Dictionary<string, List<int>> kennedy = new Dictionary<string, List<int>>();
            inputFile = File.OpenText("Kennedy.txt");
            string[] line = File.ReadAllLines("Kennedy.txt");
            while (!inputFile.EndOfStream)
            {
                kennedy.Add(line, List<int>);
            }

I know the kennedy.add part is wrong, but I do not know what to include to make it function.



from Recent Questions - Stack Overflow https://ift.tt/2Tv8dyl
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation