Why can't I use the enumerator of an array, instead of implementing it myself?

前端 未结 2 759
借酒劲吻你
借酒劲吻你 2020-12-15 05:49

I have some code like this:

public class EffectValues : IEnumerable
{
    public object [ ] Values { get; set; }

    public IEnumerator

        
      
      
      
2条回答
  •  一个人的身影
    2020-12-15 06:19

    You have to cast the array to IEnumerable to be able to access the generic enumerator:

    public IEnumerator GetEnumerator() {
      return ((IEnumerable)this.Values).GetEnumerator();
    }
    
        

    提交回复
    热议问题