谁能给个泛型的例子?

ytzz 2007-04-13 03:59:53
如题。
详细点。马上结贴
...全文
297 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
hy_lihuan 2007-04-13
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/5463/5463932.xml?temp=6.858462E-02
这个是另一贴!
tiantian1980 2007-04-13
  • 打赏
  • 举报
回复
上面的发错了,是反射的.
ytzz 2007-04-13
  • 打赏
  • 举报
回复
晕。。。怎么一会这么多贴?我都给分了。。
hy_lihuan 2007-04-13
  • 打赏
  • 举报
回复
ytzz (冲星中!多给分!谢谢!)
hxling1981(冷雨星空)
你们是一个人把,这样倒分不太好吧!
mingwj1980 2007-04-13
  • 打赏
  • 举报
回复
Arraylist list = new Arraylist();

这句你肯定能看懂,List就是Arraylist这种集合的类生成的对像


Arraylist<string> list = new Arraylist<string>();
而这句,意思就是告诉你这个集合里面的东西其实是字符串而已,类别更加清楚,所以很容易理解的
fxqyyzg 2007-04-13
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/5449/5449447.xml?temp=.5922815
tiantian1980 2007-04-13
  • 打赏
  • 举报
回复
http://blog.csdn.net/21aspnet/category/285687.aspx经典的东东,不要说我没告诉你!
blackant2 2007-04-13
  • 打赏
  • 举报
回复
没有安装msdn?
hertcloud 2007-04-13
  • 打赏
  • 举报
回复
楼主看看 Petshop4 相当 经典...
viena 2007-04-13
  • 打赏
  • 举报
回复
还有IList<T>
Red_angelX 2007-04-13
  • 打赏
  • 举报
回复
剩下的操作同ArrayList
kmiaoer 2007-04-13
  • 打赏
  • 举报
回复
学习
Red_angelX 2007-04-13
  • 打赏
  • 举报
回复
List<string> list = new List<string>();
viena 2007-04-13
  • 打赏
  • 举报
回复
最常用的,就是
List<T>
mingwj1980 2007-04-13
  • 打赏
  • 举报
回复
PETSHOP里有就,其实就是一种强类型的集合而已
chaoren1641 2007-04-13
  • 打赏
  • 举报
回复
http://blog.csdn.net/cuoguo1111/archive/2007/02/13/1508980.aspx
chaoren1641 2007-04-13
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Text;

namespace GenericTest
{
 class GenericClass
 {
  //申明一个泛型方法
  public T getvalue<T>(T t)
  {
   return t;
  }

  //调用泛型方法
  //注意:在调用泛型方法时,对泛型方法的类型参数实例化
  public int useMethod()
  {
   return this.getvalue<int>(10);
  }

  //重载getvalue方法
  public int getvalue(int i)
  {
   return i;
  }
 }

 //下面演示覆盖
 //要注意的是,泛型方法被覆盖时,约束被默认继承,不需要重新指定约束关系
 abstract class Parent
 {
  public abstract K TEST<K, V>(K k, V v) where K : V;
 }

 class Child : Parent
 {
  public override T TEST<T, S>(T t, S s)
  {
   return t;
  }
 }
}
ytzz 2007-04-13
  • 打赏
  • 举报
回复
谢谢,收到。
ytzz 2007-04-13
  • 打赏
  • 举报
回复
sdytzz@hotmail.com
疯狂秀才2018 2007-04-13
  • 打赏
  • 举报
回复
给我你的Email,
我发给你!

7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧