简体   繁体   中英

Define body for an interface method

I have an interface and I implement this interface in a class like this:

    interface ITest
    {
        bool Method();
    }

    class MyClass:ITest
    {
        bool ITest.Method()
        {
            return true;
        }

        public bool Method()
        {
            return false;
        }
    }

What does the method ITest.Method() in class do?

For example, if you have the following code:

ITest first= new MyClass();

first.Method() will call bool ITest.Method();

or if you have :

MyClass second= new MyClass();

second.Method() will call bool Method()

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