易丰科技

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3394|回复: 0
打印 上一主题 下一主题

Predicate type in the C#

[复制链接]

111

主题

117

帖子

3588

积分

论坛元老

Rank: 8Rank: 8

积分
3588
跳转到指定楼层
楼主
发表于 2011-10-16 14:20:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

  1. using System;

  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         //
  7.         // This Predicate instance returns true if the argument is one.
  8.         //
  9.         Predicate<int> isOne =
  10.             x => x == 1;
  11.         //
  12.         // This Predicate returns true if the argument is greater than 4.
  13.         //
  14.         Predicate<int> isGreaterEqualFive =
  15.             (int x) => x >= 5;

  16.         //
  17.         // Test the Predicate instances with various parameters.
  18.         //
  19.         Console.WriteLine(isOne.Invoke(1));
  20.         Console.WriteLine(isOne.Invoke(2));
  21.         Console.WriteLine(isGreaterEqualFive.Invoke(3));
  22.         Console.WriteLine(isGreaterEqualFive.Invoke(10));
  23.     }
  24. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|易丰科技

GMT+8, 2024-10-14 05:12 , Processed in 0.045822 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表