.net - How to pass a value to a C# generic? -
in c++ templates have feature can pass value argument template of function. how can same in c#?
for instance, want similar following:
template <unsigned n> struct factorial { enum { result = n * factorial<n - 1>::result; }; }; template <> struct factorial<0> { enum { result = 1; }; };
but in c#. how can this?
by way, actual need them involves generating classes on demand (with few static values changed), presented code example.
c# generics not c++ templates in way. work types , not values.
Comments
Post a Comment