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?

 

A MyClass= myClass = gcnew MyClass();
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 Type= t = Type::GetType("MyClass");
MethodInfo= m = t->GetMethod("MyMethod");
int i =
(int)m->Invoke(this, gcnew array<Object=> { 1 }); 

C MyClass= myClass = gcnew MyClass();
Type= t = MyClass::typeid;
MethodInfo= m = t->GetMethod("MyMethod");
int i =
(int)m->Invoke(myClass, gcnew array<Object=> { 1 }); 

D MyClass= myClass = gcnew MyClass();
Type= t = MyClass::typeid;
MethodInfo= m = t->GetMethod("MyClass.MyMethod");
int i =
(int)m->Invoke(myClass, gcnew array<Object=> { 1 }); 

+ Answer
+ Report
Total Preview: 652

Copyright © 2024. Powered by Intellect Software Ltd