Skip to content

Instantly share code, notes, and snippets.

@dotMorten
Created June 6, 2014 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotMorten/d80007a832e2ba178041 to your computer and use it in GitHub Desktop.
Save dotMorten/d80007a832e2ba178041 to your computer and use it in GitHub Desktop.
The C# Generics problem
public abstract class ClassA<T> where T : ClassB { }
public abstract class ClassB { }
public class SubClassB : ClassB { }
public class SubClassA : ClassA<SubClassB> { }
ClassA<ClassB> obj = new SubClassA(); //Won't compile :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment