zoukankan      html  css  js  c++  java
  • 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();

            }

        }

    }

     

     

  • 相关阅读:
    C++基于范围的for循环性能测试(针对std::vector)
    C++ 中std::function 、std::bind的使用和lambda的使用
    C++ auto 关键字的使用
    C++内存管理解析
    c++类内存分布解析
    Windows上编译GRPC
    在从1到n的正数中1出现的次数
    POJ 1009 解题报告
    Cheat Engine 笔记
    Cheat Engine 教程 Step 9
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1754198.html
Copyright © 2011-2022 走看看