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);
    }
    }
    }
  • 相关阅读:
    【LVS 】NAT方式实现过程
    【 LVS 】类型及算法
    [ 总结 ] RHEL6/Centos6 使用OpenLDAP集中管理用户帐号
    [ 手记 ] 关于tomcat开机启动设置问题
    [ 总结 ] nginx 负载均衡 及 缓存
    Mac
    Swift
    Swift
    Cocoapods
    Swift
  • 原文地址:https://www.cnblogs.com/pavkoo/p/1782777.html
Copyright © 2011-2022 走看看