Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions about Reflection

Status
Not open for further replies.

Kostarsus

Programmer
Nov 30, 2000
86
DE
Hello,

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.
Code:
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()
   {}
}

The class CSolute is saved in an arraylist and all fields are filled (the 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 Kostarsus


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top