GrammarBuilder ImplicitWideningImplicitImplicitImplicit Conversion (SemanticResultValue to GrammarBuilder) |
GrammarBuilder Class Example See Also Send Feedback |
Converts a SemanticResultValue object to a GrammarBuilder object.
Namespace:
Microsoft.Speech.Recognition
Assembly:
Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Widening Operator CType ( _ semanticValue As SemanticResultValue _ ) As GrammarBuilder |
Visual Basic (Usage) |
---|
Dim input As SemanticResultValue Dim output As GrammarBuilder output = CType(input, GrammarBuilder) |
C# |
---|
public static implicit operator GrammarBuilder ( SemanticResultValue semanticValue ) |
Parameters
- semanticValue
- Type: Microsoft.Speech.Recognition..::..SemanticResultValue
The SemanticResultValue object to convert.
Return Value
Type: Microsoft.Speech.Recognition..::..GrammarBuilderThe converted SemanticResultValue object.
Remarks
Implicit conversion creates a new instance of GrammarBuilder. This conversion operator is equivalent to calling GrammarBuilder(SemanticResultValue) and specifying semanticValue for the value.
Examples
The following example creates a speech recognition grammar that can recognize a response to a "yes" or "no" question. The implicit conversion operator is used in the construction of a SemanticResultValue object from a Choicesobject, in the construction of a Choices object from two SemanticResultValue objects, and in the construction of a Grammar object from a SemanticResultKey object.
C# | Copy Code |
---|---|
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";
|