• Predicate委托


    1.      定义

    表示定义一组条件并确定指定对象是否符合这些条件的方法。

    public delegate bool Predicate<T>(

        T obj

    );

    2.      示例

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

     

    namespace PredicateApp

    {

        class Program

        {

            static void Main(string[] args)

            {

     

                MyPredicate<int> myBigger5=

                    delegate(int number)

                    {

                        if (number > 5)

                        {

                            return true;

                        }

                        return false;

                    };

     

                Console.WriteLine("----------MyPredicate------------");

                Console.WriteLine(myBigger5(1));

     

                Console.WriteLine(myBigger5(5));

     

                Console.WriteLine(myBigger5(10));

     

                Predicate<int> big5 = delegate(int number)

                {

                    if (number > 5)

                    {

                        return true;

                    }

                    return false;

                };

     

                Console.WriteLine("----------Predicate------------");

                Console.WriteLine(big5(1));

     

                Console.WriteLine(big5(5));

     

                Console.WriteLine(big5(10));

     

                Console.ReadLine();

            }

        }

    }

     

     

  • 相关阅读:
    3.2 Program Encodings 程序编码
    Describe your home
    Building vs solution in command line
    找到适合自己的人生轨迹 Angkor:
    每个月总有那么几天不想学习,不想写代码 Angkor:
    Linux下的Memcache安装
    敏捷开发之 12条敏捷原则
    为什么要用NIO
    memcached server LRU 深入分析
    Linux 脚本编写基础
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1754198.html
Copyright © 2020-2023  润新知