T
Tony
Hello!
I just come to think about one thing and that is
the statement below.
public class Tree<T> where T : IComparable<T>
This is a correct statement and it works as expected.
But now to my question when you use generic classes like this will you
always use the construction with where T : . . .
I mean writing something like
public class Tree<T> : IComparable<T>
generate compile error.
For me it's more or less the same writing
public class Tree<T> where T : IComparable<T>
or
public class Tree<T> : IComparable<T>
It's obvious that type T must implement IComparable and use type T insted of
object in method CompareTo
I can't really see why you have to use the where T.
//Tony
I just come to think about one thing and that is
the statement below.
public class Tree<T> where T : IComparable<T>
This is a correct statement and it works as expected.
But now to my question when you use generic classes like this will you
always use the construction with where T : . . .
I mean writing something like
public class Tree<T> : IComparable<T>
generate compile error.
For me it's more or less the same writing
public class Tree<T> where T : IComparable<T>
or
public class Tree<T> : IComparable<T>
It's obvious that type T must implement IComparable and use type T insted of
object in method CompareTo
I can't really see why you have to use the where T.
//Tony