例子:
public class MyList<T> : List<T> {
public MyList(List<T> list) {
this = list; // this is basically what I want, but doesn't work
base = list; // this also doesn't work
}
}
有什么解决办法吗?或者我想要实现的只是一个坏主意?
动机:我想向 List 对象添加自定义函数。
请您参考如下方法:
如果您使用的是 .Net Framework 3.5,那么在列表上定义扩展方法不是更容易吗?类似...
public static class MyListExtensionClass
{
public static void MyList<T>(this List<T> list)
{
// Your stuff
}
}
