zoukankan      html  css  js  c++  java
  • c#基础语法之 解读delegate create by lee

    首先自己给委托下人地址 定义为 be defined as

     他其实是在求函数的入口地址,并且带标记,标记他是一个函数入口地址,举例说明如下,欢迎大家与我讨论。

    代码

            
            
    static public void Main()
            {
                MyClass p 
    = new MyClass();

                p.InstanceMethod(); 
    //直接调用的方式
                MyClass.StaticMethod(); //直接调用的方式



                
    // Map the delegate to the instance method:
                MyDelegate d = new MyDelegate(p.InstanceMethod);
                d(); 
    //以委托为中介,进行转换,进而可以函数 作函数的参数传递函数
           
                
    // Map to the static method:
                d = new MyDelegate(MyClass.StaticMethod);
                d();  
    //以委托为中介,进行转换,进而可以函数 作函数的参数传递函数

               
            }
        }


        
    // delegate declaration
        delegate void MyDelegate();

        
    public class MyClass
        {
            
    public void InstanceMethod()
            {
                Console.WriteLine(
    "A message from the instance method.");
            }

            
    static public void StaticMethod()
            {
                Console.WriteLine(
    "A message from the static method.");
            }
        }

    这样你就能利用他的这个参数作为函数的 参数 来传递函数了,举例说明如下:

  • 相关阅读:
    时序数据库入门
    MySQL执行计划extra中的using index 和 using where using index 的区别
    ETL的详细解释定义
    六种 主流ETL 工具的比较(DataPipeline,Kettle,Talend,Informatica,Datax ,Oracle Goldengate)
    使用 IntraWeb (37)
    使用 IntraWeb (36)
    使用 IntraWeb (35)
    使用 IntraWeb (34)
    使用 IntraWeb (33)
    使用 IntraWeb (32)
  • 原文地址:https://www.cnblogs.com/chenli0513/p/1887316.html
Copyright © 2011-2022 走看看