想做一个特别的ArrayList

yuaiwu 2003-07-17 02:49:22
现在arrayList里面的元素都是object型,现在我想做一个特别的,不知是不是该从它继承,只想使用某种特定类型的元素,用法和arrayList一样,
但是现在我继续它以后,Add不让我override,索引器也不允许返回不同类型的值
应该怎么办?是不是从别的地方继承?
谢谢
...全文
14 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xixigongzhu 2003-07-17
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.Web.Services.Description;

public class BindingCollection : CollectionBase {
public BindingCollection(){
}

public Binding this[int index]{
get {
return (Binding) List[index];
}
set {
List[index] = value;
}
}

public int Add(Binding binding ){
return List.Add(binding);
}

public bool Contains(Binding binding){
return List.Contains( binding );
}

public void CopyTo( Binding[] bindings , int index ){
List.CopyTo(bindings, index);
}

public int IndexOf( Binding binding ){
return List.IndexOf( binding );
}

public void Insert( int index , Binding binding ){
List.Insert( index , binding );
}

public void Remove( Binding binding ){
List.Remove( binding );
}
}
yuaiwu 2003-07-17
  • 打赏
  • 举报
回复
不会用,有一些Current,Movenext之类的让我去实现,不会做,而且没有arrayList的方便性了
现在我把一个ArrayList型变量做为了个内部变量,都是对它操作,来实现的,我 知道这不是标准做法,但是简单的实现了我的要求,呵
谢谢
panyee 2003-07-17
  • 打赏
  • 举报
回复
public class CUserArray:IEnumerator

继承IEnumerator可以实现你要的功能

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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