Export (0) Print
Expand All

Grammar.RuleName Property

Gets the name of the root rule or entry point of a Grammar object.

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

public string RuleName { get; }

Property Value

Type: System.String
The RuleName property returns the identifier for the root rule of the referenced speech recognition grammar. The default is null.

To construct a Grammar object and set the name for its root rule, use one of the Grammar constructors that takes the ruleName parameter.

If the root rule of a Grammar has no name, the property returns null.

The root rules of Grammar instances constructed from GrammarBuilder objects typically have no name, so RuleName returns null.

The following example writes information about a Grammar object to the console.

private static void DumpGrammarStatus(Grammar item)
{
  Console.WriteLine("Grammar name is {0}:", item.Name);
  Console.WriteLine("  The Grammar {0} loaded.",
    item.Loaded ? "is" : "is not");
  Console.WriteLine("  The Grammar {0} enabled.",
    item.Enabled ? "is" : "is not");
  if (item.RuleName != null)
  {
    Console.WriteLine("  The root rule is {0}.", item.RuleName);
  }
  else
  {
    Console.WriteLine("  The Grammar does not specify a root rule.");
  }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft