Console.Write("В методе Set(double, double). ");
x = (int)a;
y = (int)b;
Show();
}
public void Show() {
Console.WriteLine("Значение x: {0}, значение у: {1}", x, y);
}
}
class InvokeMethDemo {
static void Main() {
Type t = typeof(MyClass);
MyClass reflectOb = new MyClass(10, 20);
int val;
Console.WriteLine("Вызов методов, определенных в классе " + t.Name);
Console.WriteLine();
MethodInfo[] mi = t.GetMethods();
// Вызвать каждый метод,
foreach (MethodInfo m in mi) {
// Получить параметры.
ParameterInfo[] pi = m.GetParameters();
if (m.Name.CompareTo("Set") == 0 && pi[0].ParameterType == typeof(int)) {
object[] args = new object[2];
args[0] = 9;
args[1] = 18;
m.Invoke(reflectOb, args);
}
else if (m.Name.CompareTo("Set") == 0 &&
pi[0].ParameterType == typeof(double)) {
object[] args = new object[2];