我使用以下代码使myClass能够使用foreach。但我对编程比较陌生,在理解下面的代码方面有一些困难。我在评论中描述了我的问题。如果能提供一些信息,我将不胜感激。public class MyClass : IEnumerable<string> //1) What is IEnumerator for?// Whats the difference between <e
我知道如何实现非泛型IEnumerable,如下所示:using System.Collections;
{IEnumerable有一个通用版本,IEnumerable<T>,但我不知道如何实现它。如果我将using System.Collections.Generic;添加到我的using指令中,然后更改:
c
我应该调整我的InvItems类以使用IEnumerable接口,而不是使用IEnumerable<>接口。然而,当我调整类时,我的List<InvItem>会弹出错误,我不明白为什么。我想我必须转换列表,但我不太确定如何转换(我只找到了使用IEnumerable <>接口的说明)。谢谢你的帮助!invItems;
public Inv