H
hardieca
My apologies if this gets posted twice...
I am trying to determine whether or not a class has a function, and if
it does, build a reference to it dynamically which I can then use to
access the original function's functionality.
So, for the first part, I'm looking for some way to do the following:
if (hasMember(object o, string member){
//Processing
Then, if the object does have the function, I want to build a reference
to the function I can then use:
functionRef = buildFunctionRef(object System.Convert, string
"ToInt16");
x = functionRef("100"); // x is an int equal to 100.
It's important that the member be passed as a string as the string
parameter will be dynamically concatenated as the application runs.
I'm fairly new to C#, but I'm looking for something similar to Python's
getattr function. Let me know if I haven't been clear.
Regards,
Chris
I am trying to determine whether or not a class has a function, and if
it does, build a reference to it dynamically which I can then use to
access the original function's functionality.
So, for the first part, I'm looking for some way to do the following:
if (hasMember(object o, string member){
//Processing
Then, if the object does have the function, I want to build a reference
to the function I can then use:
functionRef = buildFunctionRef(object System.Convert, string
"ToInt16");
x = functionRef("100"); // x is an int equal to 100.
It's important that the member be passed as a string as the string
parameter will be dynamically concatenated as the application runs.
I'm fairly new to C#, but I'm looking for something similar to Python's
getattr function. Let me know if I haven't been clear.
Regards,
Chris