I have an interface declared as follows
public interface ILoadObjects<T> where T : class
{
List<T> LoadBySearch();
}
I then have a class declared as follows
public class MyTestClass : ILoadObjects<MyTestClass>
{
List<MyTestClass> ILoadObjects<MyTestClass>.LoadBySearch()
{
List<MyTestClass> list = new List<MyTestClass>();
list.Add(new MyTestClass());
return list;
}
}
Now what I'd like to do, is use that method defined in the interface against that class without having to know what the class is.
public void ExecuteTestClassMethod()
{
MyTestClass testObject = new MyTestClass();
object objectSource = testObject;
object results = ((ILoadObjects<>)objectSource).LoadBySearch();
{... do something with results ...}
}
The above obviously doesnt work, so I'd like to know how to do something along the lines of that.
Thanks