2011年11月28日
摘要: 1.Action<T> 泛型委托这个委托很好用, 不用独立的定义声明一个委托了.下面的委托代码程序还是在.net 1.x时学会的呢, 当时觉得别扭些, 但最后习惯也就习惯了, 最后还保存成模板拷贝来拷贝去的. public delegate void DelegateMessage(string username, decimal score); static void Main(string[] args) { DelegateMessage messageTarget = ShowWindowsMessage; messageTarget("lzd", 10 阅读全文
posted @ 2011-11-28 18:00 BobLiu 阅读(743) 评论(0) 推荐(0) 编辑
摘要: Nullable<T> 与 T?可空类型, 是c#2.0添加的特性, 已经不新了, 但俺还没怎么用过.1. Nullable<int> 与 int?是同样的意思. int? cc = 2; if (cc.HasValue){ Console.WriteLine(cc.Value);}2. ??是一个运算符例如 a ?? b如果a不是null就返回a; 如果a是null, b 不是null, 就返回b; 如果都是null, 就只能返回null了. 阅读全文
posted @ 2011-11-28 15:47 BobLiu 阅读(512) 评论(0) 推荐(0) 编辑
摘要: 查询两个集合中匹配数据并输出, 能写得这样容易真是让人有点震撼, 不学习真是要落伍了!using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication4{ class Program { static void Main(string[] args) { List<Product> list = new List<Product>(); list.Add(new Product("htc", 30 阅读全文
posted @ 2011-11-28 15:29 BobLiu 阅读(401) 评论(0) 推荐(0) 编辑