C# Type GetConstructors()
Description
Type GetConstructors()
returns all the public constructors
defined for the current Type.
Syntax
Type.GetConstructors()
has the following syntax.
[ComVisibleAttribute(true)]
public ConstructorInfo[] GetConstructors()
Returns
Type.GetConstructors()
method returns
Example
This example shows the output of the GetConstructors overload from a class that has two instance constructors and one static constructor.
// w w w.j a va 2 s.co m
using System;
using System.Reflection;
public class t {
public t() {}
static t() {}
public t(int i) {}
public static void Main() {
ConstructorInfo[] p = typeof(t).GetConstructors();
Console.WriteLine(p.Length);
for (int i=0;i<p.Length;i++) {
Console.WriteLine(p[i].IsStatic);
}
}
}
The code above generates the following result.