zoukankan      html  css  js  c++  java
  • ASP.NET学习之匿名方法

    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace AnonymousMethod
    {
    ///<summary>
    /// apply a delegate!
    ///</summary>
    ///<param name="s"></param>
    delegatevoid WriteString(string s);
    class Program
    {
    staticvoid Main(string[] args)
    {
    //define an instance of delegate, which is anonymous
    WriteString print =delegate(string j)
    {
    Console.WriteLine(j
    +" of Anonymous Method!");
    };
    //call the anonymouse methode
    print("The delegate using the anonymous method is called.");
    //rederict the method to a named methode
    print =new WriteString(Program.NamedMethode);
    //call the name methode
    print("The delegate using the Named Methode is called.");
    int? i =null;
    if (!i.HasValue)
    {
    Console.WriteLine(
    "oh!i have nothing");
    }
    Console.Read();
    }
    ///<summary>
    /// define a name methode
    ///</summary>
    ///<param name="k"></param>
    staticvoid NamedMethode(string k)
    {
    System.Console.WriteLine(k);
    }
    }
    }
  • 相关阅读:
    CSS部分
    css基础
    css初探
    html表单
    mysql视图 触发器 事物 函数 存储过程
    pymysql
    mysql数据备份与操作
    html基础
    mysql 索引
    tuple,list,dict,set用法
  • 原文地址:https://www.cnblogs.com/pavkoo/p/1782777.html
Copyright © 2011-2022 走看看