Link to home
Start Free TrialLog in
Avatar of thready
thready

asked on

iterators - c# - what am I missing? body of get cannot be an iterator because MyType is not an iterator interface type

Hi Experts,

I have this c# property:

        public MyClass NextObject {
            get
            {
                for(int i = 0; i < m_Objects.Count; i++)   // List<MyClass> m_Objects
                    yield return m_Objects[i];
            }
        }

Open in new window


I'm getting "The body of 'NextObject.get' cannot be an iterator block because 'MyClass' is not an iterator interface type".  How do I fix this?

Thanks!
Mike
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thready
thready

ASKER

Thanks!
Not a problem thread, glad to help.