1
Answer

Using the generic type 'System.Collections.Generic.IEnumerable' requires '1' type arguments

paulwhittaker99

paulwhittaker99

14y
12.5k
1
Hi There

I'm getting the above error message for this block of code - I've bolded the line in question, can anyone tell what I'm missing? Thanks very much in advance, Paul.

internal class GroupIterator : IEnumerable
    {
        private Regex _regex;
        private string _input;

        public GroupIterator(string input, string pattern)
        {
            _regex = new Regex(pattern, UserDefinedFunctions.Options);
            _input = input;
        }

        public IEnumerator GetEnumerator()
        {
            int index = 0;
            Match current = null;
            string[] names = _regex.GetGroupNames();
            do
            {
                index++;
                current = (current == null) ?
                    _regex.Match(_input) : current.NextMatch();
                if (current.Success)
                {
                    foreach (string name in names)
                    {
                        Group group = current.Groups[name];
                        if (group.Success)
                        {
                            yield return new GroupNode(
                                index, name, group.Value);
                        }
                    }
                }
            }
            while (current.Success);
        }
    }
Answers (1)