predicate c# code example

Example 1: predicate c#

static bool IsUpperCase(string str)
{
    return str.Equals(str.ToUpper());
}

static void Main(string[] args)
{
    Predicate isUpper = IsUpperCase;

    bool result = isUpper("hello world!!");

    Console.WriteLine(result);
}

Example 2: predicate c#

static void Main(string[] args)
{
    Predicate isUpper = delegate(string s) { return s.Equals(s.ToUpper());};
    bool result = isUpper("hello world!!");
}

Example 3: predicate c#

static void Main(string[] args)
{
    Predicate isUpper = s => s.Equals(s.ToUpper());
    bool result = isUpper("hello world!!");
}

Tags:

Misc Example