It is introduced in .Net 2.0.
A predicate delegate is a delegate with the following signature:
- Return type -
bool - Argument type - generic
Example :
using System;
class Program
{
static void Main()
{
//
// This Predicate instance returns true if the argument is one.
//
Predicate isOne =
x => x == 1;
//
// This Predicate returns true if the argument is greater than 4.
//
Predicate 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));
}
}
Output
True
False
False
True
=========================
Tera hath mere kandhe per tha
Mere Panv angaro pe chalte rahe.
No comments:
Post a Comment