SrgsDocument.Root Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the root rule of the SrgsDocument class.

Namespace:   System.Speech.Recognition.SrgsGrammar
Assembly:  System.Speech (in System.Speech.dll)

member Root : SrgsRule with get, set

Property Value

Type: System.Speech.Recognition.SrgsGrammar.SrgsRule

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

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.

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; 

.NET Framework
Available since 3.0
Return to top
Show: