I'm programming a program, where I don't know which objects are needed. So I
want to use the mechanism of reflection.
I can create the objects I need by reflection, but there are some questions
I don't have a solution. Perhaps anybody can help?
First i want to write a little code down here, the code isn't so important
but it describes the structure of my classes.
Expand|Select|Wrap|Line Numbers
- public interface ITest
- {
- void Find(string keyword);
- }
- public class CTest : ITest
- {
- string index;
- void Find(string text)
- {}
- public CTest()
- {}
- }
- public class CSolute
- {
- protected ITest testclass;
- protected string text;
- public ITest Index
- {
- get{return testclass;}
- }
- public string Text
- {
- get{return text;}
- set{text=value;}
- }
- public CSolute()
- {}
- }
fields of the class CTest are filled, too)
I've managed to get an object of the class CSolute
And now my problems:
1. I want to display the classname of CSolute.testclass (not the name of the
interface!). How can I manage this?
2. How can I get the object of the class CSolute.testclass by reflection?
3. How can I invoke the method CTest.Find by reflection?
I would be glad if anyone of you have an answer.
cu Thomas