Partilhar via


SrgsDocument.Root Property

Definition

Gets or sets the root rule of the SrgsDocument class.

public:
 property System::Speech::Recognition::SrgsGrammar::SrgsRule ^ Root { System::Speech::Recognition::SrgsGrammar::SrgsRule ^ get(); void set(System::Speech::Recognition::SrgsGrammar::SrgsRule ^ value); };
public System.Speech.Recognition.SrgsGrammar.SrgsRule Root { get; set; }
member this.Root : System.Speech.Recognition.SrgsGrammar.SrgsRule with get, set
Public Property Root As SrgsRule

Property Value

Returns the rule that is designated as the root rule of the SrgsDocument.

Examples

The following example creates a rule named winnerRule, and then creates an SrgsDocument object named document. The example then calls the Add method to add the rule to the document. Finally, the example sets the document's Root property to winnerRule, thereby making it the root rule for the grammar defined by the SrgsDocument object.

SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;

SrgsDocument document = new SrgsDocument();

document.Rules.Add(winnerRule);
document.Root = winnerRule;

Remarks

The SrgsRule object must already be in the document's SrgsRulesCollection before it can be set to the root rule.

You can also set the root rule for an SrgsDocument object by using an SrgsRule object as the argument to the SrgsDocument constructor.

Applies to

See also