Type.GetConstructor Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém um construtor específico da corrente Type.
Sobrecargas
| Name | Description |
|---|---|
| GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) |
Procura um construtor cujos parâmetros correspondam aos tipos de argumento e modificadores especificados, usando as restrições de ligação especificadas e a convenção de chamada especificada. |
| GetConstructor(Type[]) |
Procura um construtor público de instância cujos parâmetros correspondam aos tipos no array especificado. |
| GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[]) |
Procura um construtor cujos parâmetros correspondam aos tipos de argumento e modificadores especificados, usando as restrições de ligação especificadas. |
GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
Procura um construtor cujos parâmetros correspondam aos tipos de argumento e modificadores especificados, usando as restrições de ligação especificadas e a convenção de chamada especificada.
public:
virtual System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public:
System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, System::Reflection::CallingConventions callConvention, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public System.Reflection.ConstructorInfo GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.ConstructorInfo GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
member this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * System.Reflection.CallingConventions * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (bindingAttr As BindingFlags, binder As Binder, callConvention As CallingConventions, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo
Parâmetros
- bindingAttr
- BindingFlags
Uma combinação bit a bit dos valores de enumeração que especifica como a pesquisa é realizada.
-ou-
Default para regressar null.
- binder
- Binder
Um objeto que define um conjunto de propriedades e permite a ligação, que pode envolver a seleção de um método sobrecarregado, a coerção dos tipos de argumentos e a invocação de um membro através da reflexão.
-ou-
Uma referência nula (Nothing em Visual Basic), para usar o DefaultBinder.
- callConvention
- CallingConventions
O objeto que especifica o conjunto de regras a usar relativamente à ordem e disposição dos argumentos, como o valor de retorno é passado, que registos são usados para argumentos e a pilha é limpo.
- types
- Type[]
Um array de Type objetos que representa o número, a ordem e o tipo dos parâmetros que o construtor deve obter.
-ou-
Um array vazio do tipo Type (ou seja, Tipo[] tipos = novo Tipo[0]) para obter um construtor que não aceita parâmetros.
- modifiers
- ParameterModifier[]
Um array de ParameterModifier objetos que representa os atributos associados ao elemento correspondente no types array. O binder padrão não processa este parâmetro.
Devoluções
Um objeto que representa o construtor e que corresponde aos requisitos especificados, se encontrado; caso contrário, null.
Implementações
- Atributos
Exceções
types é multidimensional.
-ou-
modifiers é multidimensional.
-ou-
types e modifiers não têm o mesmo comprimento.
Exemplos
O exemplo seguinte obtém o tipo de MyClass, obtém o ConstructorInfo objeto e apresentam a assinatura do construtor.
using System;
using System.Reflection;
using System.Security;
public class MyClass3
{
public MyClass3(int i) { }
public static void Main()
{
try
{
Type myType = typeof(MyClass3);
Type[] types = new Type[1];
types[0] = typeof(int);
// Get the public instance constructor that takes an integer parameter.
ConstructorInfo constructorInfoObj = myType.GetConstructor(
BindingFlags.Instance | BindingFlags.Public, null,
CallingConventions.HasThis, types, null);
if (constructorInfoObj != null)
{
Console.WriteLine("The constructor of MyClass3 that is a public " +
"instance method and takes an integer as a parameter is: ");
Console.WriteLine(constructorInfoObj.ToString());
}
else
{
Console.WriteLine("The constructor of MyClass3 that is a public instance " +
"method and takes an integer as a parameter is not available.");
}
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: " + e.Message);
}
catch (ArgumentException e)
{
Console.WriteLine("ArgumentException: " + e.Message);
}
catch (SecurityException e)
{
Console.WriteLine("SecurityException: " + e.Message);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
open System
open System.Reflection
open System.Security
type MyClass1(i: int) = class end
try
let myType = typeof<MyClass1>
let types = [| typeof<int> |]
// Get the public instance constructor that takes an integer parameter.
let constructorInfoObj = myType.GetConstructor(BindingFlags.Instance ||| BindingFlags.Public, null, CallingConventions.HasThis, types, null)
if constructorInfoObj <> null then
printfn "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: \n{constructorInfoObj}"
else
printfn "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available."
with
| :? ArgumentNullException as e ->
printfn $"ArgumentNullException: {e.Message}"
| :? ArgumentException as e ->
printfn $"ArgumentException: {e.Message}"
| :? SecurityException as e ->
printfn $"SecurityException: {e.Message}"
| e ->
printfn $"Exception: {e.Message}"
Public Class MyClass1
Public Sub New(ByVal i As Integer)
End Sub
Public Shared Sub Main()
Try
Dim myType As Type = GetType(MyClass1)
Dim types(0) As Type
types(0) = GetType(Integer)
' Get the public instance constructor that takes an integer parameter.
Dim constructorInfoObj As ConstructorInfo = _
myType.GetConstructor(BindingFlags.Instance Or _
BindingFlags.Public, Nothing, _
CallingConventions.HasThis, types, Nothing)
If Not (constructorInfoObj Is Nothing) Then
Console.WriteLine("The constructor of MyClass1 that " + _
"is a public instance method and takes an " + _
"integer as a parameter is: ")
Console.WriteLine(constructorInfoObj.ToString())
Else
Console.WriteLine("The constructor MyClass1 that " + _
"is a public instance method and takes an " + _
"integer as a parameter is not available.")
End If
Catch e As ArgumentNullException
Console.WriteLine("ArgumentNullException: " + e.Message)
Catch e As ArgumentException
Console.WriteLine("ArgumentException: " + e.Message)
Catch e As SecurityException
Console.WriteLine("SecurityException: " + e.Message)
Catch e As Exception
Console.WriteLine("Exception: " + e.Message)
End Try
End Sub
End Class
Observações
Embora o fichário padrão não processe ParameterModifier (o modifiers parâmetro), você pode usar a classe abstrata System.Reflection.Binder para escrever um fichário personalizado que processa modifiers.
ParameterModifier é utilizado apenas ao fazer chamadas através da interoperabilidade COM, e apenas os parâmetros que são passados por referência são tratados.
Se não existir correspondência exata, tentará binder coagir os tipos de parâmetros especificados no types array para selecionar uma correspondência. Se não binder conseguir selecionar uma correspondência, então null é devolvido.
As seguintes BindingFlags bandeiras de filtro podem ser usadas para definir quais os construtores a incluir na pesquisa:
Você deve especificar ou
BindingFlags.InstanceouBindingFlags.Staticpara obter um retorno.Especifique
BindingFlags.Publicincluir construtores públicos na pesquisa.Especifique
BindingFlags.NonPublicincluir construtores não públicos (ou seja, construtores privados, internos e protegidos) na pesquisa.
Consulte System.Reflection.BindingFlags para obter mais informações.
Para obter o inicializador de classes (construtor estático) usando este método, deve especificar BindingFlags.Static | BindingFlags.NonPublic (BindingFlags.StaticOrBindingFlags.NonPublic em Visual Basic). Também pode obter o inicializador de classes usando a TypeInitializer propriedade.
A tabela a seguir mostra quais membros de uma classe base são retornados pelos Get métodos ao refletir sobre um tipo.
| Tipo de Membro | Estático | Não-estático |
|---|---|---|
| Construtor | No | No |
| Campo | No | Yes. Um campo é sempre ocultado com base no nome e assinatura. |
| Event | Não aplicável | A regra comum do sistema de tipos é que a herança é a mesma dos métodos que implementam a propriedade. A reflexão trata propriedades como esconder pelo nome e assinatura. Veja a nota 2 abaixo. |
| Método | No | Yes. Um método (virtual e não virtual) pode ser ocultado por nome ou ocultado por nome e assinatura. |
| Tipo aninhado | No | No |
| Property | Não aplicável | A regra comum do sistema de tipos é que a herança é a mesma dos métodos que implementam a propriedade. A reflexão trata propriedades como esconder pelo nome e assinatura. Veja a nota 2 abaixo. |
Ocultar por nome e assinatura considera todas as partes da assinatura, incluindo modificadores personalizados, tipos de retorno, tipos de parâmetros, sentinelas e convenções de chamada não gerenciadas. Esta é uma comparação binária.
Para reflexão, as propriedades e os eventos são ocultados por nome e assinatura. Se você tiver uma propriedade com um acessador get e um set na classe base, mas a classe derivada tiver apenas um acessor get, a propriedade de classe derivada ocultará a propriedade de classe base e você não poderá acessar o setter na classe base.
Os atributos personalizados não fazem parte do sistema de tipo comum.
Note
Não podes omitir parâmetros ao procurar construtores e métodos. Só podes omitir parâmetros ao invocar.
Se o current Type representa um tipo genérico construído, esse método retorna o ConstructorInfo com os parâmetros type substituídos pelos argumentos de tipo apropriados. Se a corrente Type representa um parâmetro de tipo na definição de um tipo genérico ou método genérico, este método retorna nullsempre .
Ver também
- ConstructorInfo
- BindingFlags
- Binder
- DefaultBinder
- CallingConventions
- ParameterModifier
- GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
- GetConstructors()
Aplica-se a
GetConstructor(Type[])
Procura um construtor público de instância cujos parâmetros correspondam aos tipos no array especificado.
public:
virtual System::Reflection::ConstructorInfo ^ GetConstructor(cli::array <Type ^> ^ types);
public:
System::Reflection::ConstructorInfo ^ GetConstructor(cli::array <Type ^> ^ types);
public System.Reflection.ConstructorInfo GetConstructor(Type[] types);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.ConstructorInfo GetConstructor(Type[] types);
abstract member GetConstructor : Type[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : Type[] -> System.Reflection.ConstructorInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
abstract member GetConstructor : Type[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : Type[] -> System.Reflection.ConstructorInfo
member this.GetConstructor : Type[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (types As Type()) As ConstructorInfo
Parâmetros
- types
- Type[]
Um array de Type objetos que representa o número, ordem e tipo dos parâmetros para o construtor desejado.
-ou-
Um array vazio de Type objetos, para obter um construtor que não aceita parâmetros. Tal matriz vazia é fornecida pelo static corpo EmptyTypes.
Devoluções
Um objeto que representa o construtor de instância pública cujos parâmetros correspondem aos tipos no array de tipos de parâmetros, se encontrados; caso contrário, null.
Implementações
- Atributos
Exceções
types é multidimensional.
Exemplos
O exemplo seguinte obtém o tipo de MyClass, obtém o ConstructorInfo objeto e apresentam a assinatura do construtor.
using System;
using System.Reflection;
public class MyClass1
{
public MyClass1() { }
public MyClass1(int i) { }
public static void Main()
{
try
{
Type myType = typeof(MyClass1);
Type[] types = new Type[1];
types[0] = typeof(int);
// Get the constructor that takes an integer as a parameter.
ConstructorInfo constructorInfoObj = myType.GetConstructor(types);
if (constructorInfoObj != null)
{
Console.WriteLine("The constructor of MyClass1 that takes an " +
"integer as a parameter is: ");
Console.WriteLine(constructorInfoObj.ToString());
}
else
{
Console.WriteLine("The constructor of MyClass1 that takes an integer " +
"as a parameter is not available.");
}
}
catch (Exception e)
{
Console.WriteLine("Exception caught.");
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("Message: " + e.Message);
}
}
}
type MyClass1() =
new (i: int) = MyClass1()
try
let myType = typeof<MyClass1>
let types = [| typeof<int> |]
// Get the constructor that takes an integer as a parameter.
let constructorInfoObj = myType.GetConstructor types
if constructorInfoObj <> null then
printfn "The constructor of MyClass1 that takes an integer as a parameter is: \n{constructorInfoObj}"
else
printfn "The constructor of MyClass1 that takes an integer as a parameter is not available."
with e ->
printfn "Exception caught."
printfn $"Source: {e.Source}"
printfn $"Message: {e.Message}"
Imports System.Reflection
Imports System.Security
Public Class MyClass1
Public Sub New()
End Sub
Public Sub New(ByVal i As Integer)
End Sub
Public Shared Sub Main()
Try
Dim myType As Type = GetType(MyClass1)
Dim types(0) As Type
types(0) = GetType(Int32)
' Get the constructor that takes an integer as a parameter.
Dim constructorInfoObj As ConstructorInfo = myType.GetConstructor(types)
If Not (constructorInfoObj Is Nothing) Then
Console.WriteLine("The constructor of MyClass that takes an integer as a parameter is: ")
Console.WriteLine(constructorInfoObj.ToString())
Else
Console.WriteLine("The constructor of MyClass that takes no " + "parameters is not available.")
End If
Catch e As Exception
Console.WriteLine("Exception caught.")
Console.WriteLine(("Source: " + e.Source))
Console.WriteLine(("Message: " + e.Message))
End Try
End Sub
End Class
Observações
Esta sobrecarga de métodos procura construtores de instâncias públicas e não pode ser usada para obter um inicializador de classe (construtor estático). Para obter um inicializador de classe, use uma sobrecarga que ocupe BindingFlags, e especifique BindingFlags.Static | BindingFlags.NonPublic (BindingFlags.StaticOrBindingFlags.NonPublic em Visual Basic). Também pode obter o inicializador de classes usando a TypeInitializer propriedade.
Se o construtor solicitado não for público, este método devolve null.
Note
Não podes omitir parâmetros ao procurar construtores e métodos. Só podes omitir parâmetros ao invocar.
Se o current Type representa um tipo genérico construído, esse método retorna o ConstructorInfo com os parâmetros type substituídos pelos argumentos de tipo apropriados. Se a corrente Type representa um parâmetro de tipo na definição de um tipo genérico ou método genérico, este método retorna nullsempre .
Ver também
- ConstructorInfo
- DefaultBinder
- GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
- GetConstructors()
Aplica-se a
GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])
Procura um construtor cujos parâmetros correspondam aos tipos de argumento e modificadores especificados, usando as restrições de ligação especificadas.
public:
virtual System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public:
System::Reflection::ConstructorInfo ^ GetConstructor(System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <Type ^> ^ types, cli::array <System::Reflection::ParameterModifier> ^ modifiers);
public System.Reflection.ConstructorInfo GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type[] types, System.Reflection.ParameterModifier[] modifiers);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.ConstructorInfo GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, Type[] types, System.Reflection.ParameterModifier[] modifiers);
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
abstract member GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
override this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
member this.GetConstructor : System.Reflection.BindingFlags * System.Reflection.Binder * Type[] * System.Reflection.ParameterModifier[] -> System.Reflection.ConstructorInfo
Public Function GetConstructor (bindingAttr As BindingFlags, binder As Binder, types As Type(), modifiers As ParameterModifier()) As ConstructorInfo
Parâmetros
- bindingAttr
- BindingFlags
Uma combinação bit a bit dos valores de enumeração que especifica como a pesquisa é realizada.
-ou-
Default para regressar null.
- binder
- Binder
Um objeto que define um conjunto de propriedades e permite a ligação, que pode envolver a seleção de um método sobrecarregado, a coerção dos tipos de argumentos e a invocação de um membro através da reflexão.
-ou-
Uma referência nula (Nothing em Visual Basic), para usar o DefaultBinder.
- types
- Type[]
Um array de Type objetos que representa o número, a ordem e o tipo dos parâmetros que o construtor deve obter.
-ou-
Um array vazio do tipo Type (ou seja, Tipo[] tipos = novo Tipo[0]) para obter um construtor que não aceita parâmetros.
-ou-
- modifiers
- ParameterModifier[]
Um array de ParameterModifier objetos que representa os atributos associados ao elemento correspondente no array de tipos de parâmetros. O binder padrão não processa este parâmetro.
Devoluções
Um objeto que representa o construtor e que corresponde aos requisitos especificados, se encontrado ConstructorInfo ; caso contrário, null.
Implementações
- Atributos
Exceções
types é multidimensional.
-ou-
modifiers é multidimensional.
-ou-
types e modifiers não têm o mesmo comprimento.
Exemplos
O exemplo seguinte obtém o tipo de MyClass, obtém o ConstructorInfo objeto e apresentam a assinatura do construtor.
using System;
using System.Reflection;
using System.Security;
public class MyClass2
{
public MyClass2(int i) { }
public static void Main()
{
try
{
Type myType = typeof(MyClass2);
Type[] types = new Type[1];
types[0] = typeof(int);
// Get the constructor that is public and takes an integer parameter.
ConstructorInfo constructorInfoObj = myType.GetConstructor(
BindingFlags.Instance | BindingFlags.Public, null, types, null);
if (constructorInfoObj != null)
{
Console.WriteLine("The constructor of MyClass2 that is public " +
"and takes an integer as a parameter is:");
Console.WriteLine(constructorInfoObj.ToString());
}
else
{
Console.WriteLine("The constructor of the MyClass2 that is public " +
"and takes an integer as a parameter is not available.");
}
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: " + e.Message);
}
catch (ArgumentException e)
{
Console.WriteLine("ArgumentException: " + e.Message);
}
catch (SecurityException e)
{
Console.WriteLine("SecurityException: " + e.Message);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
open System
open System.Reflection
open System.Security
type MyClass1(i: int) = class end
try
let myType = typeof<MyClass1>
let types = [| typeof<int> |]
// Get the constructor that is public and takes an integer parameter.
let constructorInfoObj = myType.GetConstructor(BindingFlags.Instance ||| BindingFlags.Public, null, types, null)
if constructorInfoObj <> null then
printfn "The constructor of MyClass1 that is public and takes an integer as a parameter is:\n{constructorInfoObj}"
else
printfn "The constructor of the MyClass1 that is public and takes an integer as a parameter is not available."
with
| :? ArgumentNullException as e ->
printfn $"ArgumentNullException: {e.Message}"
| :? ArgumentException as e ->
printfn $"ArgumentException: {e.Message}"
| :? SecurityException as e ->
printfn $"SecurityException: {e.Message}"
| e ->
printfn $"Exception: {e.Message}"
Imports System.Reflection
Imports System.Security
Public Class MyClass1
Public Sub New(ByVal i As Integer)
End Sub
Public Shared Sub Main()
Try
Dim myType As Type = GetType(MyClass1)
Dim types(0) As Type
types(0) = GetType(Integer)
' Get the constructor that is public and takes an integer parameter.
Dim constructorInfoObj As ConstructorInfo = _
myType.GetConstructor(BindingFlags.Instance Or _
BindingFlags.Public, Nothing, types, Nothing)
If Not (constructorInfoObj Is Nothing) Then
Console.WriteLine("The constructor of MyClass1 that is " + _
"public and takes an integer as a parameter is ")
Console.WriteLine(constructorInfoObj.ToString())
Else
Console.WriteLine("The constructor of MyClass1 that is " + _
"public and takes an integer as a parameter is not available.")
End If
Catch e As ArgumentNullException
Console.WriteLine("ArgumentNullException: " + e.Message)
Catch e As ArgumentException
Console.WriteLine("ArgumentException: " + e.Message)
Catch e As SecurityException
Console.WriteLine("SecurityException: " + e.Message)
Catch e As Exception
Console.WriteLine("Exception: " + e.Message)
End Try
End Sub
End Class
Observações
Se não existir correspondência exata, tentará binder coagir os tipos de parâmetros especificados no types array para selecionar uma correspondência. Se não binder conseguir selecionar uma correspondência, então null é devolvido.
As seguintes BindingFlags bandeiras de filtro podem ser usadas para definir quais os construtores a incluir na pesquisa:
Você deve especificar ou
BindingFlags.InstanceouBindingFlags.Staticpara obter um retorno.Especifique
BindingFlags.Publicincluir construtores públicos na pesquisa.Especifique
BindingFlags.NonPublicincluir construtores não públicos (ou seja, construtores privados, internos e protegidos) na pesquisa.
Consulte System.Reflection.BindingFlags para obter mais informações.
Para obter o inicializador de classes (construtor estático) usando este overload de método, deve especificar BindingFlags.Static | BindingFlags.NonPublic (BindingFlags.StaticOrBindingFlags.NonPublic em Visual Basic). Também pode obter o inicializador de classes usando a TypeInitializer propriedade.
Note
Não podes omitir parâmetros ao procurar construtores e métodos. Só podes omitir parâmetros ao invocar.
Se o current Type representa um tipo genérico construído, esse método retorna o ConstructorInfo com os parâmetros type substituídos pelos argumentos de tipo apropriados. Se a corrente Type representa um parâmetro de tipo na definição de um tipo genérico ou método genérico, este método retorna nullsempre .
Ver também
- ConstructorInfo
- BindingFlags
- Binder
- DefaultBinder
- ParameterModifier
- GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])
- GetConstructors()