Export (0) Print
Expand All

Choices Constructor

Initializes a new instance of the Choices class.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Choices() Initializes a new instance of the Choices class that contains an empty set of alternatives.
Public method Choices(GrammarBuilder[]) Initializes a new instance of the Choices class from an array containing one or more GrammarBuilder objects.
Public method Choices(String[]) Initializes a new instance of the Choices class from an array containing one or more String objects.
Top

You can construct a Choices object using a default constructor (which returns an empty object), from a group of String objects, or a from set of GrammarBuilder objects.

Because the GrammarBuilder object supports implicit conversion from SemanticResultValue and SemanticResultKey, a Choices can be constructed from an array of these objects using a cast.

The following example uses Choices objects to create two lists of alternatives.

The first Choices object is constructed from an array of String objects. The other Choices object is constructed from an array of GrammarBuilder objects which have been implicitly converted by a cast.

The example uses a GrammarBuilder object to assemble a phrase, using the Choices objects and two additional strings, that can be used to recognize speech input in the form of "Call [contactlList] on [phoneType] phone" , for example "Call Jane on cell phone".

public GrammarBuilder ChoicesContructor2 ()
{
    GrammarBuilder gb = new GrammarBuilder ();
    Choices phoneType = new Choices (new string[] {"cell", "home", "work"});
    Choices contactList = new Choices (new GrammarBuilder[] {(GrammarBuilder) "Mark", (GrammarBuilder) "Jane", (GrammarBuilder) "Frank"});
    gb.Append ("Call");
    gb.Append (contactList);
    gb.Append ("on");
    gb.Append (phoneType);
    gb.Append ("phone");
    return gb;
}
Show:
© 2014 Microsoft