共用方式為


SpeechRecognitionEngine.Grammars 屬性

定義

取得在這個 Grammar 執行個體中載入之 SpeechRecognitionEngine 物件的集合。

public:
 property System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::Grammar ^> ^ Grammars { System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::Grammar ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.Grammar> Grammars { get; }
member this.Grammars : System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.Grammar>
Public ReadOnly Property Grammars As ReadOnlyCollection(Of Grammar)

屬性值

ReadOnlyCollection<Grammar>

Grammar 物件的集合。

範例

下列範例會針對語音辨識器目前載入的每個語音辨識文法,將資訊輸出到主控台。

重要

複製文法集合,以避免在此方法列舉集合的元素時修改集合的錯誤。

private static void ListGrammars(SpeechRecognitionEngine recognizer)  
{  
  string qualifier;  
  List<Grammar> grammars = new List<Grammar>(recognizer.Grammars);  
  foreach (Grammar g in grammars)  
  {  
    qualifier = (g.Enabled) ? "enabled" : "disabled";  

    Console.WriteLine("Grammar {0} is loaded and is {1}.",  
      g.Name, qualifier);  
  }  
}  

適用於

另請參閱