You must define a second non-generic interface, for example:
public interface ILoadObjects<T> : ILoadObjects where T : class { List<T> LoadBySearch(); } public interface ILoadObjects { IList LoadBySearch(); }
And declare your class as follows:
public class MyTestClass : ILoadObjects<MyTestClass> { public List<MyTestClass> LoadBySearch() { List<MyTestClass> list = new List<MyTestClass>(); list.Add(new MyTestClass()); return list; } IList ILoadObjects.LoadBySearch() { return this.LoadBySearch(); } }
The IEnumerable<T> and IEnumerable interfaces work the same way.
Now you can call the ILoadObjects.LoadBySearch method as follows:
((ILoadObjects)objectSource).LoadBySearch();
source share