c# - Overloading generic type parameters disallowed? -


it's part curiosity , part because trying use this. if have following definitions, not allowed compiler because says member defined. what's reasoning behind not allowing exclusive overloads of generic type parameters?

void get<t>() t: struct {} void get<t>() t: class {} 

it seems me there's no inherent problem this. 1 might argue not clear compiler should choose in cases definitions overlap (but common resolution seems specific match first).

can me understand or point resource reasoning behind disallowing this?

eric lippert answered one, in blog post on generic constraints , method signatures: http://blogs.msdn.com/b/ericlippert/archive/2009/12/10/constraints-are-not-part-of-the-signature.aspx

constraints on generic types not part of method signatures in clr, therefore can't have 2 methods differ in generic type constraints. without clr support quite fiddly c# support these in sensible fashion compatible other .net languages.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -