简体   繁体   中英

What does it means class that implements IEnumerable<object[]>

What does it means class that implements IEnumerable<object[]>? (in the specific case it is an abstract class but I'm not sure it is relevant) Does it means that it should contains IEnumerable<object[]> property?

class <some class name>: IEnumerable<object[]>

For the class to implement an interface it means it contains every property or method that is declared in that interface publicly or implicitly accessible. So from your example you are using generic version of IEnumerable interface with object[] as type parameter. From the comment about abstract classes I gather you are new to c# so lets simplify this example by removing the generics from it using not generic version .

public interface IEnumerable{
    IEnumerator GetEnumerator();
}   

Interface declares one method and you just have to have it like this:

public class SomeClass: IEnumerable
{
    public IEnumerator GetEnumerator()
    {     
    }
}

or

public class SomeClass: IEnumerable
{
    IEnumerator IEnumerable.GetEnumerator()
    {     
    }
}

for the class to implement an interface it means its instances can be assigned to a variable of that type so usually you do variables like this:

SomeClass instance = new SomeClass();

but you now can:

IEnumerable instance = new SomeClass();

this will work for method parameters as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM