While reading about generics I came across those two chunks of code, and I was wondering if they were identical?
public abstract class Search<T, TCollection, TCriteria>
where TCollection : Collection<Name>
where T : Name
AND:
public abstract class Search<Name, Collection<Name>, TCriteria>
As Lasse pointed out, your second version doesn’t compile. If you changed it to
it would compile, but it wouldn’t do what you wanted it to do: This just specifies a generic class with three type parameters called
Name,CollectionandTCriteria. But it doesn’t limit them in any way, so you could create an instance likeSearch<int, long, ulong>.Type parameters usually start with
T, but the language doesn’t enforce it in any way.So the difference is that the second version doesn’t work, use the first one.