C# code to handle different classes with same method names

前端 未结 9 1572
夕颜
夕颜 2020-12-10 01:56

Let\'s say you have two different C# classes A and B that while not deriving from the same base class do share some of the same names for methods.

9条回答
  •  醉话见心
    2020-12-10 02:41

    This will work in C# 4:

    public void make_connection(dynamic x)
    {
      x.connect() ;
      // Do some more stuff...
      x.disconnect() ;
      return ;
    }
    

提交回复
热议问题