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

//组合接口
//1.通过组合接口不仅可以在语义上相关多个接口组合成单个接口,还可以在需要时将方法添加进新的组合接口
namespace InterfaceApp
{
    public class Control
    { 
    }
    public interface IDragDrop
    {
        void Drag();
        void Drop();
    }
    public interface ISerializable
    {
        void Serialize();
    }
    //将IDragDrop,ISerializable组成一个接口ICombo
    public interface ICombo : IDragDrop, ISerializable
    {
    }
    public class MyTreeView : Control, ICombo
    {
        public void Drag()
        {
            Console.WriteLine("MyTreeView.Drag called");
        }
        public void Drop()
        {
            Console.WriteLine("MyTreeView.Drop called");
        }
        public void Serialize()
        {
            Console.WriteLine("MyTreeView.Serialize called");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            MyTreeView tree = new MyTreeView();
            tree.Drag();
            tree.Drop();
            tree.Serialize();
            Console.ReadKey();
        }
    }
}

相关文章:

  • 2021-12-07
  • 2021-10-08
  • 2021-08-10
  • 2022-03-01
  • 2021-05-26
  • 2021-05-19
  • 2021-04-10
猜你喜欢
  • 2022-12-23
  • 2021-06-10
  • 2021-12-24
  • 2021-09-06
  • 2022-02-05
  • 2022-12-23
相关资源
相似解决方案