Share via


SrgsDocument.Root 屬性

定義

取得或設定 SrgsDocument 類別的根規則。

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

屬性值

傳回指定為 SrgsDocument 根規則的規則。

範例

下列範例會建立名為 的規則 winnerRule ,然後建立 SrgsDocument 名為 document 的物件。 然後範例會 Add 呼叫 方法,將規則新增至檔。 最後,此範例會將檔的 Root 屬性設定為 winnerRule ,藉此讓它 root rule 成為 物件所定義文法的 SrgsDocument

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

SrgsDocument document = new SrgsDocument();

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

備註

物件 SrgsRule 必須已經位於檔的 SrgsRulesCollection 中,才能將其設定為 根規則

您也可以使用 SrgsRule 物件做為建構函式的引數 SrgsDocument ,為物件設定根規則 SrgsDocument

適用於

另請參閱