Delegate至少0个参数,至多32个参数,可以无返回值,也可以指定返回值类型。这个是祖宗。
  Func可以接受0个至16个传入参数,必须具有返回值。
  Action可以接受0个至16个传入参数,无返回值。
  Predicate只能接受一个传入参数,返回值为bool类型。

public delegate bool Predicate<in T>(T obj);
public delegate TResult Func<in T, out TResult>(T arg);
Func<T, bool> :表示有传入T类型的参数,返回值为bool的委托
Predicate<T>:表示有传入T类型的参数,返回值为bool的委托
static void Main(string[] args)
{
Predicate<int> myPredicate = i => i > ;
Func<int, bool> myFunc = i => i > ;
List<int> list = new List<int>();
list.Add();
list.Add();
list.Add();
list.Add();
List<int> newList = list.FindAll(myPredicate);
List<int> newListFunc = list.Where(myFunc).ToList();
Console.ReadKey();
}
看到Predicate和Func接受的是完全相同的Lambada表达式,
而且执行结果newList和newListFunc完全相同。
 
http://blog.csdn.net/rye_grass/article/details/66041423  C#中的Predicate<T>与Func<T, bool>

(转)C#中的Predicate<T>与Func<T, bool>的更多相关文章

  1. C#中Predicate<T>与Func<T, bool>泛型委托的用法实例

    本文以实例形式分析了C#中Predicate<T>与Func<T, bool>泛型委托的用法,分享给大家供大家参考之用.具体如下: 先来看看下面的例子: 1 2 3 4 5 6 ...

  2. Predicate<T>与Func<T, bool>泛型委托

    引用别人的: static void Main(string[] args) { List<string> l = new List<string>(); l.Add(&quo ...

  3. .NET Core中合并Expression<Func<T,bool>>的正确姿势

    这是在昨天的 .NET Core 迁移中遇到的问题,之前在 .NET Framework 中是这样合并 Expression<Func<T,bool>> 的: public s ...

  4. 表达式拼接Expression<Func<IEntityMapper, bool>> predicate

    /// <summary> /// 重写以筛选出当前上下文的实体映射信息 /// </summary> protected override IEnumerable<IE ...

  5. EF Core 封装方法Expression<Func<TObject, bool>>与Func<TObject, bool>区别

    unc<TObject, bool>是委托(delegate) Expression<Func<TObject, bool>>是表达式 Expression编译后就 ...

  6. lambda表达式Expression<Func<Person, bool>> 、Func<Person, bool>区别

    前言: 自己通过lambda表达式的封装,将对应的表达式转成字符串的过程中,对lambda表达式有了新的认识 原因: 很多开发者对lambda表达式Expression<Func<Pers ...

  7. .NetCore 扩展封装 Expression<Func<T, bool>> 查询条件遇到的问题

    前面的文章封装了查询条件 自己去组装条件,但是对 And  Or  这种组合支持很差,但是也不是不能支持,只是要写更多的代码看起来很臃肿 根据 Where(Expression<Func< ...

  8. Entity Framework 动态构造Lambda表达式Expression<Func<T, bool>>

    using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; us ...

  9. Expression<Func<T, bool>>与Func<T, bool>的区别

    转自:http://www.cnblogs.com/wow-xc/articles/4952233.html Func<TObject, bool>是委托(delegate) Expres ...

随机推荐

  1. EF实体类的枚举属性映射设计方法

    public class FoundationInfo { [Column("id")] public int ID { get; set; } public InvestType ...

  2. JavaScript实现把数字转换成中文

    /** * 数字转换汉字大写 * @constructor * 用法示例:new NumberToChinese(122222).toUpper(); new NumberToChinese(1222 ...

  3. Android动态设置字体颜色

    步骤: 1.在values目录下的strings.xml文件中加入颜色:比方 <color name="ccc">#ccc</color> 2.假设你直接这 ...

  4. 【转载】Remote System Explorer Operation总是运行后台服务,卡死eclipse解决办法

    原来是eclipse后台进程在远程操作,就是右下角显示的“Remote System Explorer Operation”.折腾了半天,在Stack Overflow找到答案(源地址).把解决方案翻 ...

  5. UILabel文字竖排

    方法一: UILabel *mindName = [[UILabel alloc]initWithFrame:kCR(, , ,)]; mindName.text = @"苏\n小\n明&q ...

  6. Java从零开始学三(public class和class)

    使用public class和class声明的区别 public class文件名称必须与类名称一致 class文件名称可以与类名称不一致  

  7. UNIX网络编程读书笔记:辅助数据

    辅助数据(ancillary data)可通过调用sendmsg和recvmsg这两个函数,使用msghdr结构中的msg_control和msg_controllen这两个成员发送和接收. 辅助数据 ...

  8. rxvt-unicode配置

    我的urxvt配置文件如下 前缀可改为rxvt然后可以使用rxvt命令启动 -/.Xresources ! urxvt color set URxvt.multichar_encoding:utf-8 ...

  9. OpenERP Client Error

    SyntaxError: JSON.parse: unexpected end of data http/mydomain:8069/web/webclient/js:23114 Solutions: ...

  10. Java中将InputStream读取为String, 各种方法的性能对比

    如下, 一共存在11种实现方式及其对应的性能测试结果: 1. 使用IOUtils.toString (Apache Utils) String result = IOUtils.toString(in ...