相关疑难解决方法(0)

.Net CLR如何在内部实现"接口"?

只是好奇.NET CLR如何在内部处理接口?

Q1]当CLR遇到类似的情况时会发生什么:

简单的界面示例.(以下同样使用.)

interface ISampleInterface
    {
        void SampleMethod();
    }

    class ImplementationClass : ISampleInterface
    {
        // Explicit interface member implementation: 
        public void SampleMethod()
        {
            // Method implementation.

        }

        static void Main()
        {
            //Declare an interface instance.
            ISampleInterface mySampleIntobj = new ImplementationClass();  // (A)
           // Call the member.
            mySampleIntobj.SampleMethod();

            // Declare an interface instance. 
            ImplementationClass myClassObj = new ImplementationClass();  // (B)
           //Call the member.
            myClassObj.SampleMethod();

        }
    }
Run Code Online (Sandbox Code Playgroud)

Q2:在上面的例子中, (A)(B)如何区分?

问题3:通用接口的处理方式是否不同?

(当问这些基本问题时,感觉就像一个菜鸟......反正....)

大家好.

c# clr interface internals

6
推荐指数
1
解决办法
2279
查看次数

标签 统计

c# ×1

clr ×1

interface ×1

internals ×1