zoukankan      html  css  js  c++  java
  • 委托简单例子

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class test : System.Web.UI.Page
    {
        public delegate string Delegate(string name);
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = People("小明", English);
            Label2.Text = People("小阳", Chinese);
        }
    
        private static string English(string name)
        {
            return "Morning," + name;
        }
        private static string Chinese(string name)
        {
            return "早上好, " + name;
        }
        //注意此方法,它接受一个GreetingDelegate类型的参数,该参数是返回值为空,参数为string类型的方法
        private static string People(string name, Delegate Make)
        {
            return Make(name);
        }
    }
  • 相关阅读:
    [日料探店] 食一料理
    工地英语
    C++20协程解糖
    C++20协程解糖
    C++20协程解糖
    单表操作
    数据库查询语句罗列
    数据库简易介绍
    mysql的常用操作
    css基础
  • 原文地址:https://www.cnblogs.com/May-day/p/5641785.html
Copyright © 2011-2022 走看看