标题:Action 委托创建委托实例和不创建委托实例调用方法的区别
取消只看楼主
平淡最真
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-6-13
 问题点数:0 回复次数:0 
Action 委托创建委托实例和不创建委托实例调用方法的区别
程序代码:
using System;
using System.Collections.Generic;
using System.Linq;

namespace PropertySample
{
    class Program
    {
        static void Main(string[] args)
        {
            Calculator calculator = new Calculator();
            Action action1 = calculator.Report;               //
            Action action2 = new Action(calculator.Report);   //
            action1();
            action2();
        }
    }

    class Calculator
    {
        public void Report()
        {
            Console.WriteLine("I have 3 methods.");
        }
    }
}

请教一下 程序中画下划线的两句程序都可以实现一样的委托效果,但是这两句有什么区别?感谢
搜索更多相关主题的帖子: 委托 实例 创建 区别 Action 
2020-06-13 22:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502110-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.602372 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved