title: Best way, how to assign voice command to event / method in C#
body: <p>in Visual Studio I´m creating application which use speech recognition for application control. </p>
  
  <p>I´d like to ask you for help about what is the best way how to assign voice command to method. </p>
  
  <p>I´m using Grammar Builder and Choices: </p>
  
  <pre><code>//Create Grammar Builder with Choices
   GrammarBuilder slovnik = new GrammarBuilder();
   slovnik.Append(new Choices("stop", "go"));
  </code></pre>
  
  <p>And If I´d like to assign one word from the choices to (voice command) to method (for example - showing Message Box) - In event handler I´m using if command:</p>
  
  <pre><code>void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
          {
              if (e.Result.Text == "stop")
              {
                  MessageBox.Show("Some message, that the voice command works");
              }
          }
  </code></pre>
  
  <p>My question is - Is the If clause the best way how to join word / phrase from grammar to method / event or is there any better (cleaner) solution how to do that?
  I´m using <em>C#</em> and <em>System.Speech.Recognition.SpeechRecognitionEngine</em>.</p>
  
  <p>Thanks a lot!</p>