title: Overload extension method for multiple classes
body: <p>In my project I have a class that represents a certain document type. Each class has its own properties and methods although there are some similarities between them.</p>
  
  <p>I am trying to implement an extension method for each class that has the same name (<em>method overloading</em>) but I am getting an ambiguous call error</p>
  
  <p>Code to explain further</p>
  
  <p>Document Type A class representation:</p>
  
  <pre><code>static class DocType_A
  {
      private static XElement baseDocType_A = XmlFiles[0].Root;
  
      // Extension Method
      internal static IEnumerable&lt;ViewData&gt; AsViewData(this IEnumerable&lt;XElement&gt; result)
      {
          return
              from doc in result select new ViewData { };
      }
  
  
      // Contains methods for querying through the XML file of this [DocType_A] type
      internal static class Query
      {
          internal static IEnumerable&lt;XElement&gt; ByStatusOrAny(byte status = 0)
          {
              return baseDocType_A.Descendants("DocType_A").Select(doc =&gt; doc);
          }
  
          internal static IEnumerable&lt;XElement&gt; Expired()
          {
              return baseDocType_A.Descendants("DocType_A").Where("some conditions").Select(doc =&gt; doc);
          }
  
      }
  
      // Represents the data needed to be displayed to the user via the DGV
      internal class ViewData
      {
          // [DocType_A] related Property 
      }
  
      internal class Counter
      {
          // some property
      }
  
  }
  </code></pre>
  
  <p>Document Type B class representation:</p>
  
  <pre><code>static class DocType_B
  {
      private static XElement baseDocType_B = XmlFiles[1].Root;
  
      // Extension Method
      internal static IEnumerable&lt;ViewData&gt; AsViewData(this IEnumerable&lt;XElement&gt; result)
      {
          return
              from doc in result select new ViewData { };
      }
  
  
      // Contains methods for querying through the XML file of this [DocType_A] type
      internal static class Query
      {
          internal static IEnumerable&lt;XElement&gt; ByStatusOrAny(byte status = 0)
          {
              return baseDocType_B.Descendants("DocType_B").Select(doc =&gt; doc);
          }
  
          internal static IEnumerable&lt;XElement&gt; Expired()
          {
              return baseDocType_B.Descendants("DocType_B").Where("some conditions").Select(doc =&gt; doc);
          }
  
      }
  
      // Represents the data needed to be displayed to the user via the DGV
      internal class ViewData
      {
          // [DocType_B] related Property 
      }
  
      internal class Counter
      {
          // some property
      }
  }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>class SomeApplicationClass
  {
      void Method()
      {
          IEnumerable&lt;DocType_A.ViewData&gt; query = DocType_A.Query.ByStatusOrAny().AsViewData();
      }
  
      void SomeOtherMethod()
      {
          IEnumerable&lt;DocType_B.ViewData&gt; query = DocType_B.Query.ByStatusOrAny().AsViewData();
      }
  }
  </code></pre>
  
  <p>But I am getting ambiguous call error.</p>
  
  <p>Is is possible to make extension method for each class with the same name?</p>
  
  <p><a href="https://i.stack.imgur.com/ZOSoQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZOSoQ.png" alt="error"></a></p>