易丰科技
标题:
Predicate type in the C#
[打印本页]
作者:
Calvin
时间:
2011-10-16 14:20
标题:
Predicate type in the C#
using System;
class Program
{
static void Main()
{
//
// This Predicate instance returns true if the argument is one.
//
Predicate<int> isOne =
x => x == 1;
//
// This Predicate returns true if the argument is greater than 4.
//
Predicate<int> isGreaterEqualFive =
(int x) => x >= 5;
//
// Test the Predicate instances with various parameters.
//
Console.WriteLine(isOne.Invoke(1));
Console.WriteLine(isOne.Invoke(2));
Console.WriteLine(isGreaterEqualFive.Invoke(3));
Console.WriteLine(isGreaterEqualFive.Invoke(10));
}
}
复制代码
欢迎光临 易丰科技 (http://forum.yftek.com/)
Powered by Discuz! X3