.net - Does C# generics support type signature constraints? -
one of benefits c++ templates (implicitly) can require type signature (e.g. type t needs have function x takes no parameters , returns int). c# generics support similar?
i aware of constraints based on base class or interface not looking for.
(as c++ programmer learning c# might mistaken feature want in c#. comments on appriciated well...)
nothing except constraints have seen (which do, fair, cover lot of common scenarios). there common workarounds:
dynamic
, in 4.0- manual duck-typing using either reflection or il generation etc
none of these have static type-checking etc, though.
Comments
Post a Comment