共用方式為


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這個方法傳回的 相當於下列任一項所傳回的 。

適用於

另請參閱