using System; using System.Text.RegularExpressions; class Program { static void Main() { string pattern = @"(\w+)\s(\d+)"; Regex rgx = new Regex(pattern); Console.WriteLine("Group numbers for pattern {0}:", pattern); int[] groupNumbers = rgx.GetGroupNumbers(); foreach (int i in groupNumbers) Console.Write("{0} ", i); Console.WriteLine(); } }In this example, we define a regular expression pattern with two capture groups. We use the Regex class to construct a regular expression object and call the GetGroupNumbers method to get an array of group numbers. Finally, we iterate over the array and display the group numbers on the console. Package Library: The System.Text.RegularExpressions namespace is part of the .NET Framework Class Library, which is included with all versions of the .NET Framework.