2013年11月28日

多播委托

摘要: /*多播委托*/using System;namespace Frank{ public class Test { public static void Main(string[] args) { Action operations = MathOperations.MultiplyByTwo; operations += MathOperations.Square; ProcessAndDisplayNumber(operations,20.00);//一次执行多个方法,如果一个方法抛出了异常,那么后面的方法就不会被执行。 //为了避免方法抛... 阅读全文

posted @ 2013-11-28 17:05 wp456 阅读(175) 评论(0) 推荐(0)

委托练习一

摘要: /*委托*/using System;namespace Frank{ public class Test { private delegate string GetAString();//定义委托 private delegate double DoubleOp(double x);//定义第二个委托 public static void Main(string[] args) { GetAString str = new GetAString(1.ToString); GetAString str2 = 1.ToString;//自动类型推断 ... 阅读全文

posted @ 2013-11-28 14:42 wp456 阅读(140) 评论(0) 推荐(0)

params、explicit、可选参数和implicit的使用

摘要: /*params、explicit、可选参数和implicit的使用explicit 显示的implicit 隐士的params 可变参数必须是参数列表最后一个*/using System;namespace Frank{ public class Test { public int Count{get;set;} public static void Main(string[] args) { Test t = new Test(); t.Count = 10; Test2 t2 = new Test2(); t2.Count = 20; ... 阅读全文

posted @ 2013-11-28 10:46 wp456 阅读(227) 评论(0) 推荐(0)

导航