What are the differences between Generics in C# and Java… and Templates in C++?
Hi all,
I am experienced C++ p
C# generics are totally different from C++.
In C#, the compiler basically compiles one class definition for all object types, and a class definition per value type.
In C++, each type gets its own class definitions.
The constraints are just for the compiler so you can infer stuff from other locations.
I'd recommend looking at the Action
, Func
and Predicate
delegates and the associated IEnumerable
extension methods. Use lambda functions with those and you'll see what the constraints doing.