You can if you add a generic type constraint:

public class GenericFoo&lt;TFrom, TTo&gt;
    where TFrom : MyExtendedType
    where TTo : MyType
{
   public TTo SomeMethod(TFrom A)
   {
      return (TTo)A.Bar();
   }
}


This will be enough to get it to compile, though you will still get a run-time error if no cast exists from MyType to TTo.

Further Reading


where (generic type constraint) (C# Reference)


Can I call an extension method from inside a generic class?
My app is already on the App Store, but now I'm creating an Apple Watch Extension which also means storing data in a Shared Group. 

How do I go about moving the data from where it's currently stored (Core Data &amp; UserDefaults) for the customers that have already downloaded my app, the first time they launch the new update?

What's the most efficient and least resource intensive way of doing this, and only doing it for old users the first time they open the new update?
