Creating objects dynamically

R

Raj

I have an application which has included an assembly.

From the application how can I create objects dynamically by passing the
name of the object as string?

Thank you

Regards
Raj
 
S

Scott M.

Will the potentially needed objects be of unpredictable types and/or a lot
of different potential types?

If not, you could use a switch statement to test for the appropriate string
and instantiate the type accordingly. If not, you'll probably need to do it
via the types in System.Reflection.

-Scott
 
F

Family Tree Mike

Raj said:
I have an application which has included an assembly.

From the application how can I create objects dynamically by passing the
name of the object as string?

Thank you

Regards
Raj

Activator.CreateInstance() is one possibility.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top