|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Método Type.GetMethod (String, Type[])
Namespace: System
Assembly: mscorlib (em mscorlib.dll)
Parâmetros
- name
- Tipo: System.String
A cadeia de caracteres que contém o nome do método público para obter.
- types
- Tipo: System.Type[]
Uma matriz de Type objetos representando o número, a ordem, e o tipo dos parâmetros para o método obtém. - ou - Uma matriz vazia de Type objetos (de maneira esperada pelo campo de EmptyTypes ) para obter um método que não leva nenhum parâmetro.
Valor de retorno
Tipo: System.Reflection.MethodInfoImplementações
_Type.GetMethod(String, Type[])| Exceção | Condição |
|---|---|
| AmbiguousMatchException | |
| ArgumentNullException | |
| ArgumentException |
Observação |
|---|
Observação |
|---|
Observação |
|---|
using System; using System.Reflection; class Program { // Methods to get: public void MethodA(int i, int j) { } public void MethodA(int[] i) { } public unsafe void MethodA(int* i) { } public void MethodA(ref int r) {} // Method that takes an out parameter: public void MethodA(int i, out int o) { o = 100;} static void Main(string[] args) { MethodInfo mInfo; // Get MethodA(int i, int i) mInfo = typeof(Program).GetMethod("MethodA", new Type[] { typeof(int), typeof(int) }); Console.WriteLine("Found method: {0}", mInfo); // Get MethodA(int[] i) mInfo = typeof(Program).GetMethod("MethodA", new Type[] { typeof(int[]) }); Console.WriteLine("Found method: {0}", mInfo); // Get MethodA(int* i) mInfo = typeof(Program).GetMethod("MethodA", new Type[] { typeof(int).MakePointerType() }); Console.WriteLine("Found method: {0}", mInfo); // Get MethodA(ref int r) mInfo = typeof(Program).GetMethod("MethodA", new Type[] { typeof(int).MakeByRefType() }); Console.WriteLine("Found method: {0}", mInfo); // Get MethodA(int i, out int o) mInfo = typeof(Program).GetMethod("MethodA", new Type[] { typeof(int), typeof(int).MakeByRefType() }); Console.WriteLine("Found method: {0}", mInfo); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Função Server Core sem suporte), Windows Server 2008 R2 (Função Server Core com suporte com o SP1 ou posterior, Itanium sem suporte)
O .NET Framework não oferece suporte a todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte .Requisitos de sistema do NET Framework.
Observação