Sunday, January 24, 2010

Generics

Generics. They're generic. Sssss...

Good link:
Something I was wondering about recently was how to define constraints upon multiple generic types. Eg: If I have a class definition with more than one generic:
public class MyClass

How do I specify constraints (restrictions to the base types which the generic types can inherit from)? Answer (from the link above [5th code paragraph]):

public class MyClass
where T : String
where K : IComparable

Easy when you know how.

No comments:

Post a Comment