coding_幽谷草

博客园 首页 联系 订阅 管理

随笔分类 -  C#编程基础

摘要:泛型:通过参数化类型来实现在同一份代码上操作多种数据类型。利用“参数化类型”将类型抽象化,从而实现灵活的复用。例子代码:class Program { static void Main(string[] args) { int obj = 2; Test<int> test = new Test<int>(obj); Console.WriteLine("int:" + test.obj); string obj2 = "hello world"; Test<string> test1 = new Test<st 阅读全文
posted @ 2013-01-06 10:12 coding_幽谷草 阅读(220) 评论(0) 推荐(0)