Is it possible to see which constructor was the generic one?
internal class Foo<T>
{
public Foo( T value ) {}
public Foo( string value ) {}
}
var constructors = typeof( Foo<string> ).GetConstructors();
The property 'ContainsGenericParameters' returns me for both constructors false. Is there any way to find out that constructors[0] is the generic one? They both have the same signature, but I would like to call the "real" string one.
EDIT:
I want to invoke the given type using
ilGen.Emit( OpCodes.Newobj, constructorInfo );
so I need to work with the bound version. But I would like to invoke the "best" constructor. That should be the standard behaviour. When I call
new Foo<string>()
the constructor with the string-signature (and not the one with the generic signature) is called. The same should happen with my code.