What's the syntax to require T also be IComparable in this class definition?
public class EditItems<T> : Form
What's the syntax to require T also be IComparable in this class definition?
public class EditItems<T> : Form
Use a type constraint (see MSDN):
public class EditItems<T> : Form where T : IComparable
You can use just where T : IComparable
as shown by other answers. I find it's typically more helpful to constrain it with:
public class EditItems<T> : Form where T : IComparable<T>
That says it has to be a type which is comparable with itself.
For one thing, for value types this avoids boxing. For another, it means you're less likely to try to compare two values which aren't really comparable.