title: How can I apply a common extension method to multiple unrelated types in a third party SDK?
body: <p>I'm beginning to fall in love with Extension Methods, but I just don't know how to create an EM only for a determinate Object type.</p>
  
  <p>I have for example:</p>
  
  <pre><code>public static void AddPhoneNumberToContact(this Contact contact, PhoneType type, String number)
  {
      lock (contact)
      {
          PhoneRow pr = PhoneRow.CreateNew();
          pr.SetDefaults();
          pr.PtypeIdx = type;
          pr.PhoneNumber = number;
          contact.Phones.Add(pr);
          pr = null;
      }
  }
  </code></pre>
  
  <p>My problem is that I want to also Have this method in the Person object, and that is why I named </p>
  
  <pre><code>AddPhoneNumberToContact
  AddPhoneNumberToPerson
  </code></pre>
  
  <p>Is there a way to have AddPhoneNumber and deal with the object that is provided?</p>
  
  <p>or the solution is to have</p>
  
  <pre><code>public static void AddPhoneNumber(this object contact, ...
  {
     ...
  
     if(typeof(Contact) == contact)
        ((Contact)contact).Phones.Add(pr);
     else if(typeof(Person) == contact)
        ((Person)contact).Phones.Add(pr);
  }
  </code></pre>
  
  <p>Thank you.</p>