0

i'm having the class name as string format "MyClass",i want to create a object for that class where i am referring this class namespace in dll.

my requirement is:

MyClass myClassObj=new MyClass();

all i am having is string name= "MyClass";

so, by using the string name is there anyway to convert string as class object??

I had tried giving "using NotCurrentProject.Entities"

string selectItem="myString";
Type elementType = Type.GetType("NotCurrentProject.Entities." + selectedEntity + ");
object o = Activator.CreateInstance(elementType);
  • I'm pretty sure you're looking for `Reflection` – Jonesopolis Nov 04 '14 at 16:30
  • 1
    Yes: http://stackoverflow.com/questions/223952/c-sharp-create-an-instance-of-a-class-from-a-string – Jay Nov 04 '14 at 16:30
  • Yes I'm looking for Reflection, but all I am having is just a String format of Class name(of other dll), which I am referring in current project. if I want to use as class object I should get Type of object, so for me its showing null because I am using the class which I referred in dll not of same executable project. So can you please help me?? – Ravikumar Chunduri Nov 05 '14 at 05:22

0 Answers0