c# - 向我的类(class)添加功能

标签 c# list generics

我有一个类,这个类中有一个List,我想在我的类中添加一个调用List的Where函数的Where函数,像这样:

 public class MyClass<T> where T : class
 {    
    public Func<T, IEnumerable<T>>  Where{ get; set; }
    public List<T> mylist = new List<T>();
    public MyClass()
    {
         Where = mylist.Where;
    }
 }

我遇到了错误:

No overload for 'Where' matches delegate 'Func<T, IEnumerable<T>>

最佳答案

你的代表有错误的类型,它应该是:

public Func<Func<T, bool>, IEnumerable<T>> Where { get; set; }

关于c# - 向我的类(class)添加功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35374203/

相关文章:

c# - 如何对泛型约束类使用方法隐藏(新)

c# - 如何在 C# 中动态转换泛型列表?

c# - 如何解决泛型方法中类型推断的局限性

c# - 条形码扫描仪输入后自动触发事件

c# - Visual Studio 扩展获取项目路径

python - 在 Python 中一次遍历列表选择多个元素

list - 索引映射/过滤的无限列表是否会将映射/过滤函数应用于索引之前的所有元素?

c# - 按 PrintScreen 后创建图像文件

c# - 跨页发布 GridView

python - 查找二维列表中特定列的长度