只是好奇 .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();
}
}
Q2:在上面的例子中, (A)和(B)是如何区分的?
Q3:通用接口的处理方式不同吗?
(在问这些基本问题时感觉像个菜鸟......无论如何......)
谢谢大家。