Wednesday, April 1, 2015

What is the technology here(IEnumerable)?

So for the method



public static IEnumerable<object> AllParents(object obj)
{
while (true)
{
obj
= GetParentObject(obj);

if (obj == null)
yield break;

yield return obj;
}
}

Is it implicit or explicit implement? I suppose



Implicit Interface Implementtation



public class MyClass : InterfaceOne, InterfaceTwo
{
public void InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}
}

interface InterfaceOne
{
void InterfaceMethod();
}

interface InterfaceTwo
{
void InterfaceMethod();
}


Explicit Interface Implementation



public class MyClass : InterfaceOne, InterfaceTwo
{
void InterfaceOne.InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}

void InterfaceTwo.InterfaceMethod()
{
Console.WriteLine("Which interface method is this?");
}
}

interface InterfaceOne
{
void InterfaceMethod();
}

interface InterfaceTwo
{
void InterfaceMethod();
}


But my method's format doesn't match either of one.


No comments:

Post a Comment