Anders Inteview: Generics in C#, Java, and C++

Part VII of Anders' interview series on artima is up...

Comments (4)

  1. damien morton says:

    a query about generics:

    is it possible to spcialize a generic class using the where clause:

    class Foo<A> where A: IComparable

    // specific implimentation for A implements ICOmparable

    class Foo<A>:

    // general implimentation, for where A does not implement IComparable

  2. Eric says:

    It’s not possible to do it through constraints

    It is possible to do it using run-time support. You’d write the class without the constraint, and then check in your code if A implements IComparable:

    IComparable comparable = A as IComparable;

    if (comparable != null)






Skip to main content