Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help me in this.

Im passing a string to a method where the string is actually a class name.
Now I want to cast that string into a class, so that I can call the function in that class dynamically.

The passing string is Dynamic.

how can I solve this issue.....
please help me.....
Updated 8-Jul-12 22:26pm

1 solution

To do this, you use reflection.
You can use Activator.CreateInstance[^].

E.g. var instance = Activator.CreateInstance("Assenbly",className);
Share this answer
Manas Bhardwaj 9-Jul-12 4:37am    
Correct +5!
mavericksoft 9-Jul-12 4:41am    
Its not working
Tried this already
Abhinav S 9-Jul-12 4:56am    
Not working?
Abhinav S 9-Jul-12 4:56am    
Thanks Manas.
dan!sh 9-Jul-12 4:58am    
Or Lambda expressions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900