Choices.ToGrammarBuilder 方法

定义

GrammarBuilder 对象返回此 Choices 对象。

public:
 System::Speech::Recognition::GrammarBuilder ^ ToGrammarBuilder();
public System.Speech.Recognition.GrammarBuilder ToGrammarBuilder ();
member this.ToGrammarBuilder : unit -> System.Speech.Recognition.GrammarBuilder
Public Function ToGrammarBuilder () As GrammarBuilder

返回

GrammarBuilder

一个 GrammarBuilder,匹配此 Choices 对象。

示例

以下示例创建用于更改背景色的语音识别语法。

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;  
}  

注解

GrammarBuilder此方法返回的等效于以下任一返回的方法。

适用于

另请参阅