Любые аргументы, которые требуется передать методу, указываются в массиве
В приведенном ниже примере программы рефлексия используется для создания экземпляра объекта класса MyClass.
// Создать объект с помощью рефлексии.
using System;
using System.Reflection;
class MyClass { int x; int y;
l
public MyClass(int i) {
Console.WriteLine('Конструирование класса MyClass(int, int). '); x = у = i;
}
public MyClass(int i, int j) {
Console.WriteLine('Конструирование класса MyClass(int, int). '); x = i;
У = j;
Show () ;
public int Sum() {
return x+y;
}
public bool IsBetween (int i) {
if((x < i) && (i < y)) return true; else return false;
}
public void Set(int a, int b) {
Console.Write('В методе Set (int, int). ') ; x = a;
У = b;
Show () ;
}
// Перегрузить метод Set.
public void Set(double a, double b) {
Console.Write('В методе(double, double). '); ¦
x = (int) a; у = (int) b;
Show();
}
public void Show() {
Console.WriteLine('Значение x: {0}, значение у: {1}', x, у);
}
}
class InvokeConsDemo { static void Main() {
Type t = typeof(MyClass); int val;
// Получить сведения о конструкторе.
Constructorlnfo[] ci = t.GetConstructors();
Console.WriteLine('Доступные конструкторы: '); foreach(Constructorlnfo с in ci) {
// Вывести возвращаемый тип и имя.
Console.Write(' ' + t.Name + '(');
// Вывести параметры.
Parameterlnfo[] pi = с.GetParameters() ;
for(int i=0; i-< pi.Length; i++) {
Console.Write(pi[i].ParameterType.Name + ' ' + pi[i].Name); if (i + 1 < pi.Length) Console.Write
