摘要: 参数中的问好(?)表示可空类型;例如: public ActionResult ShowArticles(DateTime ? date) { if (!date.HasValue) { date=DateTime.Now; ViewData["Message"] = date; } return View(); }参数为null 总结(?)1. 任意一个可为空的值类型都可以与 Object 共存,而不会被认为是错误的不明确的重载,但是 Object 永远不会被调用 2. String、DateTime等无法与其他非 Object 类型作为两个重载,会产生不能明确调用的错误 阅读全文
posted @ 2011-11-23 14:02 Lovey 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 一,委托的使用基本步骤:1,声明委托类型 public delegate void MyDelegate(string name ,int age);2,创建一个委托,指引方法到委托 MyDelegate handler=new MyDelegate(MehtodOfMyDelegate);// 不用构造函数的 MyDelegate handler= MehtodOfMyDelegate;3,调用委托(如果函数) handler("yindongli",25);二,异步回调(将委托作为参数传递)基本步骤同上,如:public void MethodWithCallback( 阅读全文
posted @ 2011-11-23 12:30 Lovey 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 事件事件是类在发生其关注度事情时用来提供通知单一种方式,可以使用委托和匿名方法的形式指定多个处理程序。 阅读全文
posted @ 2011-11-23 12:30 Lovey 阅读(140) 评论(0) 推荐(0) 编辑