Question:
You write the following code to implement the MyClass.MyMethod function.
public class MyClass {
public int MyMethod(int arg) {
return arg;
}
}
You need to call the MyClass.MyMethod function dynamically from an unrelated class in your assembly.
Which code segment should you use?
Type= t = MyClass::typeid;
MethodInfo= m = t->GetMethod("MyMethod");
int i =
"A Composite Solution With Just One Click" - Certification Guaranteed 231 Microsoft 70-536 Exam (int)m->Invoke(this, gcnew array<Object=> { 1 });
B
MethodInfo= m = t->GetMethod("MyMethod");
int i =
(int)m->Invoke(this, gcnew array<Object=> { 1 });
C
Type= t = MyClass::typeid;
MethodInfo= m = t->GetMethod("MyMethod");
int i =
(int)m->Invoke(myClass, gcnew array<Object=> { 1 });
D
Type= t = MyClass::typeid;
MethodInfo= m = t->GetMethod("MyClass.MyMethod");
int i =
(int)m->Invoke(myClass, gcnew array<Object=> { 1 });