title: C# overloading a generic function
body: <p>I am trying to overload a Generic method with a specific method. But he is not going to the specifiek typed method, he takes the generic method that will not be implemented.</p>
  
  <pre><code>public static class Functions&lt;TE, TC, TG&gt;
       where TE : Entity, IExternalConexioEntity
       where TC : class, IInternalConexioEntity, IObjectState
       where TG : ConexioEntity
  {
  
  public static TG ConvertToEntity(TC conexioEntity)
  {
      throw new Exception("Type not supported(" + conexioEntity.GetType() + ")");
  }
  
  public static Contact ConvertToEntity(ConexioContact synccontact)
  {
  
  }
  }
  </code></pre>
  
  <p>The method call:</p>
  
  <pre><code>result.Add(ConvertEntity(synchronizationContact));
  </code></pre>
  
  <p>And the syncrhonizationContact is also a generic type <code>where TC : class, IInternalConexioEntity, IObjectState</code>. So the actual type is ConexioContact.</p>
  
  <p>But he is not running to the second method and my value is of type ConexioContact.</p>
  
  <pre><code>Conexio.Data.Entities.Conexio.ConexioContact
  System.AggregateException: One or more errors occurred. ---&gt; System.Exception: Type not supported(Conexio.Data.Entities.Conexio.ConexioContact)
     at Conexio.Core.Orchestration.Functions`3.ConvertToEntity(TC conexioEntity) in 
  d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Functions.cs:line 187
     at Conexio.Core.Orchestration.Contacts.Doubtfuls.SearchDoubtfuls`3.ConvertEntity(TC entity) in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\Doubtfuls\SearchDoubtfuls.cs:line 107
     at Conexio.Core.Orchestration.Contacts.Doubtfuls.SearchDoubtfuls`3.&lt;SearchAsync&gt;d__5.MoveNext() in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\Doubtfuls\SearchDoubtfuls.cs:line 61
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at Conexio.Core.Orchestration.Contacts.ConexioEntityBL`3.&lt;SearchDoubtfulsAsync&gt;d__28.MoveNext() in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\ConexioEntityBL.cs:line 323
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at System.Threading.Tasks.Task`1.get_Result()
     at Conexio.Core.Orchestration.Test.Doubtfuls.SearchContactsTest.TestSearch4() in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration.Matching.Test\Doubtfuls\SearchContactsTest.cs:line 90
  ---&gt; (Inner Exception #0) System.Exception: Type not supported(Conexio.Data.Entities.Conexio.ConexioContact)
     at Conexio.Core.Orchestration.Functions`3.ConvertToEntity(TC conexioEntity) in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Functions.cs:line 187
     at Conexio.Core.Orchestration.Contacts.Doubtfuls.SearchDoubtfuls`3.ConvertEntity(TC entity) in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\Doubtfuls\SearchDoubtfuls.cs:line 107
     at Conexio.Core.Orchestration.Contacts.Doubtfuls.SearchDoubtfuls`3.&lt;SearchAsync&gt;d__5.MoveNext() in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\Doubtfuls\SearchDoubtfuls.cs:line 61
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at Conexio.Core.Orchestration.Contacts.ConexioEntityBL`3.&lt;SearchDoubtfulsAsync&gt;d__28.MoveNext() in d:\TeamFoundation\Sources\Conexio\Conexio.Core.Orchestration\Contacts\ConexioEntityBL.cs:line 323&lt;---
  </code></pre>