using System.Collections.Generic;
public static LinkedList<WordPosition> list = new LinkedList<WordPosition>();
public static void Main()
string sentence = "this is a test";
addWordsToStructure(sentence);
LinkedListNode<WordPosition> root = list.First;
Console.WriteLine(root.Value.word + " " + root.Value.position);
public static void addWordsToStructure(string sentence)
for(int i = 0; i < sentence.Length; i++)
string word = extractWord(sentence, indexStart, indexEnd);
addWordToList(word, position);
if(i == sentence.Length - 1)
string word = extractWord(sentence, indexStart, indexEnd);
addWordToList(word, position);
public static string extractWord(string sentence, int indexStart, int indexEnd)
StringBuilder word = new StringBuilder();
for(int i = indexStart; i <= indexEnd; i++)
word.Append(sentence[i]);
public static void addWordToList(string word, int position)
WordPosition wordPos = new WordPosition(){
public class WordPosition