Dean
❔ Is a generic with a where clause equivalent to passing the same type through as a parameter
by contract (second example), if you used a specific type (such as IComparable) as a parameter, you would not be able to use the type parameter as a placeholder within the method implementation. Instead, you would need to use the specific type (such as IComparable) directly:
23 replies
❔ Is a generic with a where clause equivalent to passing the same type through as a parameter
in the first example the DoSomething method can be called with any class that implements the IComparable interface. The method can then use the CompareTo method of the IComparable interface to compare the value to the number 10.
23 replies