C# Type GetConstructors(BindingFlags)
Description
Type GetConstructors(BindingFlags)
when overridden
in a derived class, searches for the constructors defined for the current
Type, using the specified BindingFlags.
Syntax
Type.GetConstructors(BindingFlags)
has the following syntax.
[ComVisibleAttribute(true)]
public abstract ConstructorInfo[] GetConstructors(
BindingFlags bindingAttr
)
Parameters
Type.GetConstructors(BindingFlags)
has the following parameters.
bindingAttr
- A bitmask comprised of one or more BindingFlags that specify how the search is conducted.bindingAttr
- -or-bindingAttr
- Zero, to return null.
Returns
Type.GetConstructors(BindingFlags)
method returns
Example
using System;/* ww w . ja v a 2 s. c om*/
using System.Reflection;
public class t {
public t() {}
static t() {}
public t(int i) {}
public static void Main() {
ConstructorInfo[] p = typeof(t).GetConstructors(
BindingFlags.Public | BindingFlags.Static |
BindingFlags.NonPublic | BindingFlags.Instance);
Console.WriteLine(p.Length);
for (int i=0;i<p.Length;i++) {
Console.WriteLine(p[i].IsStatic);
}
}
}
The code above generates the following result.