title: How to get an index of a word in string array
body: <p>I want to get the index of a word in a string array.
  for example, the sentence I will input is 'I love you.'
  I have words[1] = love, how can I get the position of 'love' is 1? I could do it but just inside the if state. I want to bring it outside. Please help me.
  This is my code.</p>
  
  <pre><code> static void Main(string[] args)
      {
          Console.WriteLine("sentence: ");
          string a = Console.ReadLine();
          String[] words = a.Split(' ');
          List&lt;string&gt; verbs = new List&lt;string&gt;();
          verbs.Add("love");
          int i = 0;
          while (i &lt; words.Length) {
              foreach (string verb in verbs) {
                  if (words[i] == verb) {
                      int index = i;
                      Console.WriteLine(i);
  
                  }
              } i++;
          }
  
          Console.ReadKey();
      } 
  </code></pre>