Choices.ToGrammarBuilder Method

Definition

Returns a GrammarBuilder object from this Choices object.

C#
public System.Speech.Recognition.GrammarBuilder ToGrammarBuilder();

Returns

A GrammarBuilder that matches this Choices object.

Examples

The following example creates a speech recognition grammar for changing the background color.

C#
private Grammar CreateColorChoice()
{

  // Create a Choices object that contains a set of alternative colors.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder();
  gb.Append(new Choices(new string[] {"Set", "Change"}));
  gb.Append("background to");
  gb.Append(colorChoice.ToGrammarBuilder());

  Grammar grammar = new Grammar(gb);
  grammar.Name = "modify background color";

  return grammar;
}

Remarks

The GrammarBuilder returned by this method is equivalent to one returned by either of the following.

  • Calling the GrammarBuilder constructor with this object as the parameter.

  • Using the implicit or explicit cast of this object to a GrammarBuilder.

Applies to

Tuote Versiot
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

See also