In my .net windows application(c#) i want know the number of arguments in each constructor of a particular class. I get all the constructor by using reflection. Is it possible to get the number of arguments of each constructors?
Thanks in advance...
Ask for its parameters (through GetParameters()), then ask for the length of the array.
ConstructorInfo ctor = /* ... */
int numberOfArguments = ctor.GetParameters().Length;
                        Type t = typeof(...);
var constructors = t.GetConstructors();
foreach (var con in constructors)
{
    Console.WriteLine(con.GetParameters().Length);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With