I'm looking to find out how I can make a counter for the occurrence of two words in the same order in a list. As the words can vary (I am using Console.ReadLine to input them) I cannot figure out what to do. My list format is as for example:
list[0] : list[1] (1) //this is where i want count
list[1] : list[2](1)
so say the words were:
Hello : I
am : John
Hello : I

Btw the second sentence written is what I typed. when the second Hello : I is entered to the list. how could I go about setting the counter (1) to update to 2. Any help would be greatly appreciated. I'll include my relevant code thus far :
List<string> list = new List<string>();
list.AddRange(words);
list.AddRange(words1);
//counts total number of words in list.
int count = 0;
count = list.Count(d => list.Contains(d));
//Displays occurance
for (int i = 0; i < list.Count - 1; i++)
list[i] = string.Format("{0} : {1}", list[i], list[i + 1]);
list.ForEach(Console.WriteLine);