编辑代码

using System;

public interface IEnumerator
{
    bool MoveNext();
    object Current { get; }
    void Reset();
}

internal class Countdown : IEnumerator
{
    int count = 11;
    public bool MoveNext() => count-- > 0;
    public object Current => count;
    public void Reset() { throw new NotSupportedException(); }
}

// public static class Util
// {
//     public static object GetCountDown() => new CountDown();
// }

interface I1 { void Foo(); }
interface I2 { int Foo(); }

public class Widget : I1, I2
{
    public void Foo()
    {
        Console.WriteLine ("Widget's implementation of I1.Foo");
    }

    int I2.Foo()
    {
        Console.WriteLine ("Widget's implementation of I2.Foo");
        return 42;
    }
}

public class HelloWorld
{
    public static void Main()
    {
        // IEnumerator e = new Countdown();
        // while (e.MoveNext())
        // Console.Write (e.Current);       // 109876543210

        // IEnumerator e = (IEnumerator) Util.GetCountDown();
        // e.MoveNext();

        // Widget w = new Widget();
        // w.Foo();                          // Widget's implementation of I1.Foo
        // ((I1)w).Foo();                    // Widget's implementation of I1.Foo
        // ((I2)w).Foo();                    // Widget's implementation of I2.Foo
    }
}