2015年11月13日 星期五

C8_3 擴充方法實現多重繼承

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C8_3
{
    public interface ICar
    {
    }
    public static class ICarHelper
    {
        public static void ShowCar(this ICar obj)
        {
            Console.WriteLine("這汽車功能");
        }
    }
    public interface IBoat
    {
    }
    public static class IBoatHelper
    {
        public static void ShowIBoat(this IBoat obj)
        {
            Console.WriteLine("這是船功能");
        }
    }
    public class AmphibianCar : ICar, IBoat
    {
    }
    public class Test
    {
        public static void Main(string[] args)
        {
            AmphibianCar car = new AmphibianCar();
            car.ShowCar();
            car.ShowIBoat();
        }
    }
}

沒有留言: