问个接口和类的问题
using System;
using System.Threading;
namespace test
{
interface IIfc1
{
void PrintOut(string s);
}
class MyClass : IIfc1
{
public void PrintOut(string s)
{
Console.WriteLine("Calling through: {0}", s);
}
}
class Program
{
static void DoSomething(IIfc1 a)
{
a.PrintOut("a");
}
static void Main()
{
MyClass mc = new MyClass();
IIfc1 ab = mc;
DoSomething(mc);
Console.ReadKey();
}
}
DoSomething(mc); //这两句代码
Console.ReadKey(); //不理解
如何理解能将类的对象赋值给接口的对象,反之就不行,然后方法调用类的对象传入参数列表是接口的函数中?