}
}
class InvokeConsDemo {
static void Main() {
Type t = typeof(MyClass);
int val;
// Получить сведения о конструкторе.
ConstructorInfo[] ci = t.GetConstructors();
Console.WriteLine("Доступные конструкторы: ");
foreach (ConstructorInfo с in ci) {
// Вывести возвращаемый тип и имя.
Console.Write(" " + t.Name + "(");
// Вывести параметры.
ParameterInfo[] 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(", ");
}
Console.WriteLine(")");
}
Console.WriteLine();
// Найти подходящий конструктор,
int x;
for (x = 0; x < ci.Length; x++) {
ParameterInfo[] pi = ci[x].GetParameters();
if (pi.Length == 2) break;
}
if (x == ci.Length) {
Console.WriteLine("Подходящий конструктор не найден.");
return;