例如 public interface IBehavior<T> { public List<T> Value{get;set;} }public class BehaviorInt : IBehavior<int> { } public class BehaviorString : IBehavior<string> { }
[code=C#] interface IL<T> { List<T> GetList(); }class A : IL<A> { public List<A> GetList() { return ...; } } code]
public interface IBehavior<T>
{
public List<T> Value{get;set;}
}public class BehaviorInt : IBehavior<int>
{
}
public class BehaviorString : IBehavior<string>
{
}
interface IL<T>
{
List<T> GetList();
}class A : IL<A>
{
public List<A> GetList()
{
return ...;
}
}
code]
楼主可以使用泛型来实现例一:
interface ITest
{
IList<T> Method<T>();
}
例二:
interface ITest<T>
{
IList<T> Method();
}