예제 #1
0
        static void Main(string[] args)
        {
            //实例化实现了接口的类
            Person p = new Person();

            p.Name = "李四";
            p.IsMan(true);
            p.Hello();
            p.Work();

            //将接口的引用类型指向实现类
            IDemoTest idt = p;

            //将接口强制转换为Person类
            Person p1 = (Person)idt;

            p1.Hello();
            p1.Work();
        }
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IDemoTest test)
 {
     _logger = logger;
     _test   = test;
 }