共用方式為


GrammarBuilder.Implicit 運算子

定義

將其他型別轉換成 GrammarBuilder

多載

Implicit(Choices to GrammarBuilder)

Choices 物件轉換成 GrammarBuilder 物件。

Implicit(SemanticResultKey to GrammarBuilder)

SemanticResultKey 物件轉換成 GrammarBuilder 物件。

Implicit(SemanticResultValue to GrammarBuilder)

SemanticResultValue 物件轉換成 GrammarBuilder 物件。

Implicit(String to GrammarBuilder)

將字串轉換成 GrammarBuilder 物件。

備註

隱含轉換會建立的新實例 GrammarBuilder 。 您可以將下列每個類別轉換成 GrammarBuilder

每個隱含轉換相當於呼叫該函式。

Implicit(Choices to GrammarBuilder)

Choices 物件轉換成 GrammarBuilder 物件。

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::Choices ^ choices);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.Choices choices);
static member op_Implicit : System.Speech.Recognition.Choices -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (choices As Choices) As GrammarBuilder

參數

choices
Choices

要轉換的一組替代項目。

傳回

GrammarBuilder

轉換的 Choices 物件。

範例

下列範例會建立可辨識回應為「是」或「否」問題的語音辨識文法。 隱含轉換運算子用來在物件的結構中 SemanticResultValue Choices ,從兩個物件的物件結構, Choices SemanticResultValue 以及 GrammarSemanticResultKey 物件的物件結構建立物件。

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

備註

隱含轉換會建立的新實例 GrammarBuilder 。 此轉換運算子相當於呼叫 GrammarBuilder 和指定的 choices alternateChoices

這個運算子的對等方法是 GrammarBuilder.GrammarBuilder(Choices)

另請參閱

適用於

Implicit(SemanticResultKey to GrammarBuilder)

SemanticResultKey 物件轉換成 GrammarBuilder 物件。

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::SemanticResultKey ^ semanticKey);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.SemanticResultKey semanticKey);
static member op_Implicit : System.Speech.Recognition.SemanticResultKey -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (semanticKey As SemanticResultKey) As GrammarBuilder

參數

semanticKey
SemanticResultKey

要轉換的語意索引鍵。

傳回

GrammarBuilder

轉換的 SemanticResultKey 物件。

範例

下列範例會建立可辨識回應為「是」或「否」問題的語音辨識文法。 隱含轉換運算子用來在物件的結構中 SemanticResultValue Choices ,從兩個物件的物件結構, Choices SemanticResultValue 以及 GrammarSemanticResultKey 物件的物件結構建立物件。

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

備註

隱含轉換會建立的新實例 GrammarBuilder 。 此轉換運算子相當於呼叫 GrammarBuilder 和指定的 semanticKey key

這個運算子的對等方法是 GrammarBuilder.GrammarBuilder(SemanticResultKey)

另請參閱

適用於

Implicit(SemanticResultValue to GrammarBuilder)

SemanticResultValue 物件轉換成 GrammarBuilder 物件。

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::Speech::Recognition::SemanticResultValue ^ semanticValue);
public static implicit operator System.Speech.Recognition.GrammarBuilder (System.Speech.Recognition.SemanticResultValue semanticValue);
static member op_Implicit : System.Speech.Recognition.SemanticResultValue -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (semanticValue As SemanticResultValue) As GrammarBuilder

參數

semanticValue
SemanticResultValue

要進行轉換的 SemanticResultValue 物件。

傳回

GrammarBuilder

轉換的 SemanticResultValue 物件。

範例

下列範例會建立可辨識回應為「是」或「否」問題的語音辨識文法。 隱含轉換運算子用來在物件的結構中 SemanticResultValue Choices ,從兩個物件的物件結構, Choices SemanticResultValue 以及 GrammarSemanticResultKey 物件的物件結構建立物件。

Choices yesChoices = new Choices(new string[] {"yes", "yup", "yah"});  
SemanticResultValue yesValue =  
  new SemanticResultValue(yesChoices, true);  

Choices noChoices = new Choices(new string[] { "no", "nope", "nah" });  
SemanticResultValue noValue =  
  new SemanticResultValue(noChoices, false);  

SemanticResultKey yesnoKey =  
  new SemanticResultKey("yesno", new Choices(new GrammarBuilder[] { yesValue, noValue }));  

Grammar yesnoGrammar = new Grammar(yesnoKey);  
yesnoGrammar.Name = "yesno";  

備註

隱含轉換會建立的新實例 GrammarBuilder 。 此轉換運算子相當於呼叫 GrammarBuilder 和指定的 semanticValue value

這個運算子的對等方法是 GrammarBuilder.GrammarBuilder(SemanticResultValue)

另請參閱

適用於

Implicit(String to GrammarBuilder)

將字串轉換成 GrammarBuilder 物件。

public:
 static operator System::Speech::Recognition::GrammarBuilder ^(System::String ^ phrase);
public static implicit operator System.Speech.Recognition.GrammarBuilder (string phrase);
static member op_Implicit : string -> System.Speech.Recognition.GrammarBuilder
Public Shared Widening Operator CType (phrase As String) As GrammarBuilder

參數

phrase
String

要轉換的字串。

傳回

GrammarBuilder

轉換的字串。

範例

下列範例會使用 GrammarBuilderChoices 物件來建立可辨識任兩個片語 "Make background colorChoice" 或 "Set background to colorChoice" 的文法。

使用物件建立可接受的 colorChoice 值清單之後 Choices ,此範例會初始化兩個 GrammarBuilder 物件, makePhrasesetPhrase 使用字串物件的隱含轉換。

此範例最後會 GrammarChoices 轉換成物件的物件建立物件 GrammarBuilder

private Grammar CreateColorGrammar()  
{  

  // Create a set of color choices.  
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});  
  GrammarBuilder colorElement = new GrammarBuilder(colorChoice);  

  // Create grammar builders for the two versions of the phrase.  
  GrammarBuilder makePhrase = new GrammarBuilder("Make background");  
  makePhrase.Append(colorElement);  
  GrammarBuilder setPhrase = new GrammarBuilder("Set background to");  
  setPhrase.Append(colorElement);  

  // Create a Choices for the two alternative phrases, convert the Choices  
  // to a GrammarBuilder, and construct the Grammar object from the result.  
  Choices bothChoices = new Choices(new GrammarBuilder[] {makePhrase, setPhrase});  
  Grammar grammar = new Grammar((GrammarBuilder)bothChoices);  
  grammar.Name = "backgroundColor";  
  return grammar;  
}  

備註

隱含轉換會建立的新實例 GrammarBuilder 。 此轉換運算子相當於呼叫 GrammarBuilder 和指定相同的 phrase

這個運算子的對等方法是 GrammarBuilder.GrammarBuilder(String)

另請參閱

適用於