Re: problems typecast,find by function/member name and getting "managed reference"



Jon написав:
The normal way to overcome this is to use an interface if possible.
and then use Runtime.InteropServices._Type.GetInterface Method (String)
?
it's Net 2.0 :( and i need to add interface for each class and then add
functions to get variables :(. And interface will be a weak side of
design.
Otherwise, you'll need to use reflection to get the appropriate
MethodInfo and invoke it.
I *think* you're basically asking for reflection here, but I'm not
sure. Here's a sample program if you are:
static void CallMethod (Type type, object target,
string methodName)
{
MethodInfo method = type.GetMethod(methodName);
// The "null" here is because we're assuming
// the method has no parameters
method.Invoke (target, null);
}
thanks it's was a great help!.
now i only need find a way to get object by its name in string..
and still i'm not found a good solution to dynamicaly
typecast(unboxing) any *unknown type* to object at runtime.

.



Relevant Pages