C# code to handle different classes with same method names
<p>Let's say you have two different C# classes <code>A</code> and <code>B</code> that while not deriving from the same base class do share some of the same names for methods. For example, both classes have a <code>connect</code> and a <code>disconnect</code> method, as well as several others. I want to be able to write code once that will work with both types. </p>

<p>Here is a simplified example of what I would like to do:</p>

<pre><code>public void make_connection(Object x)
{
  x.connect() ;
  // Do some more stuff...
  x.disconnect() ;
  return ;
}
</code></pre>

<p>Of course, this does not compile as the Object class does not have a <code>connect</code> or <code>disconnect</code> method. </p>

<p>Is there a way to do this?</p>

<p>UPDATE. I should have made this clear from the start: I only have the DLLs for A and B and not the source.</p>
