Link to home
Start Free TrialLog in
Avatar of tradeline
tradeline

asked on

Reflection Help

I'd like to dynamically return a type of object at runtime.  It is late-bound, based on a variable set inside the class.

For example:

Vendor v = ObjectDB.getInstance(int id);

ObjectDb has a method getInstance() which determines it's return value at runtime, based on a variable "returnValue" inside of itself.  In this case, returnValue is set to "Vendor" because I want to return an instance of the Vendor class.

Can someone show me an example/best practice of how to achieve this?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops.  Use:  

object obj = new ObjectDB; // assuming you have a way to get to this object in C#