匿名方法[原创]

mac2022-06-30  103

using System; using System.Collections.Generic;

namespace AnonymityMethod {     public class AnonymityMethodExample {         /// <summary>         /// 定义委托         /// </summary>         public delegate void MyDelegate();         /// <summary>         /// 属性--获取委托实例         /// </summary>         public MyDelegate GetMyDelegate {             get {                 MyDelegate myDelegate = new MyDelegate(delegate()                 {                     Console.WriteLine("匿名方法的使用示例");                 });                 return myDelegate;             }         }     }

    public class MainClass {         public static void Main() {             AnonymityMethodExample anonymityMethodExample = new AnonymityMethodExample();             AnonymityMethodExample.MyDelegate myDelegate = anonymityMethodExample.GetMyDelegate;             myDelegate();         }     } }

转载于:https://www.cnblogs.com/ProgRamMer-cSdn/archive/2008/08/17/1269780.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)