What is the difference between the non-generic IEnumerable and the generic IEnumerable?

后端 未结 5 1835
不思量自难忘°
不思量自难忘° 2020-12-31 15:34

Sorry for such a vague question, but I have been searching around for the best part of a day, I have read article after article (and many questions here) but just cannot fin

5条回答
  •  旧巷少年郎
    2020-12-31 16:30

    An IEnumerable is basically a collection of objects. It has the method GetEnumerator() which allows you to iterate through all of the objects in the enumerable.

    An IEnumerable is basically a collection of integers. It has the method GetEnumerator() which allows you to iterate through all of the integers in the enumerable.

    IEnumerable test = method(); means that method() is getting a collection if integers from somewhere. It could be a List, an array or some other data type, but it is definitely a group of them and they are all integers, and you have the ability to iterate through them.

    This post may be helpful as well: What's the difference between IEnumerable and Array, IList and List?

提交回复
热议问题