Ami*_*itd 6 c# clr interface internals
只是好奇.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:通用接口的处理方式是否不同?
(当问这些基本问题时,感觉就像一个菜鸟......反正....)
大家好.