Re: problems typecast,find by function/member name and getting "managed reference"
- From: "SunnyDrake" <sunnydrake@xxxxx>
- Date: 25 Sep 2006 19:08:52 -0700
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 appropriatethanks it's was a great help!.
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);
}
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.
.
- Follow-Ups:
- Re: problems typecast,find by function/member name and getting "managed reference"
- From: Jon Skeet [C# MVP]
- Re: problems typecast,find by function/member name and getting "managed reference"
- References:
- problems typecast,find by function/member name and getting "managed reference"
- From: SunnyDrake
- Re: problems typecast,find by function/member name and getting "managed reference"
- From: Jon Skeet [C# MVP]
- problems typecast,find by function/member name and getting "managed reference"
- Prev by Date: Re: Serial Port keeps echoing back what I send
- Next by Date: Re: Serial Port keeps echoing back what I send
- Previous by thread: Re: problems typecast,find by function/member name and getting "managed reference"
- Next by thread: Re: problems typecast,find by function/member name and getting "managed reference"
- Index(es):
Relevant Pages
|