.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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -