首页 > 代码库 > c# 多播委托的 异常处理 如果有返回值 只返回最后一个返回值
c# 多播委托的 异常处理 如果有返回值 只返回最后一个返回值
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Func<string> f0 = f1; f0 += f12; f0 += f2; f0 += f3; f0 += f4; Delegate[] dels = f0.GetInvocationList(); foreach (Func<string> item in dels) { try { Console.WriteLine(item()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } Console.ReadKey(); } static string f1() { return "1"; } static string f2() { return "2"; } static string f3() { return "4"; } static string f4() { return "5"; } static string f12() { int b = 1; b = b - 1; int i = 1 / b; return "1ff"; } } }
c# 多播委托的 异常处理 如果有返回值 只返回最后一个返回值
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。