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();

            }

        }

    }

     

     

  • 相关阅读:
    IGeoDatabaseBridge2.GetLineOfSight
    selenium+python自动化测试--alert弹框
    web页面兼容性测试之browsershots工具使用
    selenium自动化测试之定位大全
    Android adb 命令大全
    接口自动化测试 httprunner+locust+python 安装与实践
    appium-uiautomator2-server-v0.x.x.apk does not exist or is not accessible 报错解决方法
    python基础3
    python1、2实践
    python基础2
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1754198.html
Copyright © 2011-2022 走看看