百度
网易
新浪
淘宝网
京东商城
腾迅
爱奇艺
携程旅行
58同城
东方财富
精诚软件网
Google谷歌
搜狗
C语言一级真题软件
C语言C++题库软件
Python题库软件
精诚供货单管理软件
精诚标识牌批量生成软件
产品数据分析软件-价格走势图(免费试用版)
软件发布QQ群1:198100458
软件定制QQ:1275208205
温馨提示:市场有风险,投资需谨慎!!!
首页
软件开发资料
软件定制开发
软件下载中心
计算机应用
生活杂谈
关于我们
安全退出
软件开发资料
C# ArrayList的用法
C#中split的用法
Python警告: DeprecationWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname]). 解决方法
Python报错: TypeError: ‘generator’ object is not subscriptable 解决方法
两个pythom “Windows命令行窗口”下清屏方法
Microsoft Visual Studio 2010项目创建失败 解决办法
C# winform Datagridview中固定列或固定行
Python脚本生成exe应用程序
常用特殊难打难找字符收集整理
C# 字符串格式化
c#字符串处理函数
C# 静态变量及静态函数
C#文件操作
asp.net 如何更改 menu控件的字体 颜色
c#算术运算符
C# 二进制 十进制 十六进制 相互转换
C# winform 如何在Datagridview中动态添加一列按钮列
asp.net C#设置控件高度宽度百分比或px值
实现文字滚动(marquee标记用法及在asp.net中的应用)
C#动态数组的常用方法
C# ArrayList的用法
写 sql 生成字符串
从客户端(ctl00$ContentPlaceHolder1$result="<?xml version="1.0" ...")中检测到有潜在危险的 Request.Form 值。
Asp.Net C#程序代码动态添加asp:Menu节点
怎样制作VS2008.NET应用程序的安装包
使用 Visual Studio.net 创建的Windows 安装程序包,快捷方式的目标值是错误的解决
无法识别的属性“targetFramework”。请注意属性名称区分大小写。错误解决办法
实现文字滚动(marquee标记用法及在asp.net中的应用)
C#颜色和名称样式对照表
asp.net 如何更改 menu控件的字体 颜色
C#读写注册表
使用 Visual Studio.net 创建的Windows 安装程序包,快捷方式的目标值是错误的解决
c#算术运算符
在IE浏览器中打开WORD、EXCEL、PDF和TXT文件
c#如何打印picturebox里的图片,winform怎样打印picturebox里的图片
SEO优化四个步骤,让网站排名靠前
asp.net页面布局
.NET C#获取当前网页地址
信息来源:互联网 System.Collections.ArrayList类是一个特殊的数组。通过添加和删除元素,就可以动态改变数组的长度。 一、优点 1. 支持自动改变大小的功能 2. 可以灵活的插入元素 3. 可以灵活的删除元素 4. 可以灵活访问元素 二、局限性 跟一般的数组比起来,速度上差些 三、添加元素 1.public virtual int Add(object value); 将对象添加到ArrayList的结尾处 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); 内容为abcde 2.public virtual void Insert(int index,object value); 将元素插入ArrayList的指定索引处 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.Insert(0,"aa"); 结果为aaabcde 3.public virtual void InsertRange(int index,ICollectionc); 将集合中的某个元素插入ArrayList的指定索引处 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); ArrayList list2=new ArrayList(); list2.Add("tt"); list2.Add("ttt"); aList.InsertRange(2,list2); 结果为abtttttcde 四、删除 a)public virtual void Remove(object obj); 从ArrayList中移除特定对象的第一个匹配项,注意是第一个 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.Remove("a"); 结果为bcde 2.public virtual void RemoveAt(intindex); 移除ArrayList的指定索引处的元素 aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.RemoveAt(0); 结果为bcde 3.public virtual void RemoveRange(int index,int count); 从ArrayList中移除一定范围的元素。Index表示索引,count表示从索引处开始的数目 aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.RemoveRange(1,3); 结果为ae 4.public virtual void Clear(); 从ArrayList中移除所有元素。 五、排序 a)public virtual void Sort(); 对ArrayList或它的一部分中的元素进行排序。 ArrayListaList=newArrayList(); aList.Add("e"); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); DropDownList1.DataSource=aList;//DropDown ListDropDownList1; DropDownList1.DataBind(); 结果为eabcd ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.Sort();//排序 DropDownList1.DataSource=aList;//DropDownListDropDownList1; DropDownList1.DataBind(); 结果为abcde b)public virtual void Reverse(); 将ArrayList或它的一部分中元素的顺序反转。 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); aList.Reverse();//反转 DropDownList1.DataSource=aList;//DropDownListDropDownList1; DropDownList1.DataBind(); 结果为edcba 六、查找 a)public virtual int IndexOf(object); b)public virtual int IndexOf(object,int); c)public virtual int IndexOf(object,int,int); 返回ArrayList或它的一部分中某个值的第一个匹配项的从零开始的索引。没找到返回-1。 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e"); intnIndex=aList.IndexOf(“a”);//1 nIndex=aList.IndexOf(“p”);//没找到,-1 d)public virtual int LastIndexOf(object); e)public virtual int LastIndexOf(object,int); f)public virtual int LastIndexOf(object,int,int); 返回ArrayList或它的一部分中某个值的最后一个匹配项的从零开始的索引。 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("a");//同0 aList.Add("d"); aList.Add("e"); intnIndex=aList.LastIndexOf("a");//值为2而不是0 g)public virtual bool Contains(objectitem); 确定某个元素是否在ArrayList中。包含返回true,否则返回false 七、获取数组中的元素 下面以整数为例,给出获取某个元素的值的方法 ArrayList aList=new ArrayList(); for(int i=0;i<10;i++) aList.Add(i); for(i=0;i<10;i++) Textbox1.text+=(int)aList[i]+" ";//获取的方式基本与一般的数组相同,使用下标的方式进行 结果为:0 1 2 3 4 5 6 7 8 9 八、其他 1.public virtual intCapacity{get;set;} 获取或设置ArrayList可包含的元素数。 2.public virtual intCount{get;} 获取ArrayList中实际包含的元素数。 Capacity是ArrayList可以存储的元素数。Count是ArrayList中实际包含的元素数。Capacity总是大于或等于Count。如果在添加元素时,Count超过Capacity,则该列表的容量会通过自动重新分配内部数组加倍。 如果Capacity的值显式设置,则内部数组也需要重新分配以容纳指定的容量。如果Capacity被显式设置为0,则公共语言运行库将其设置为默认容量。默认容量为16。 在调用Clear后,Count为0,而此时Capacity切是默认容量16,而不是0 3.public virtual void TrimToSize(); 将容量设置为ArrayList中元素的实际数量。 如果不向列表中添加新元素,则此方法可用于最小化列表的内存系统开销。 若要完全清除列表中的所有元素,请在调用TrimToSize之前调用Clear方法。截去空ArrayList会将ArrayList的容量设置为默认容量,而不是零。 ArrayList aList=new ArrayList(); aList.Add("a"); aList.Add("b"); aList.Add("c"); aList.Add("d"); aList.Add("e");//Count=5,Capacity=16, aList.TrimToSize();//Count=Capacity=5;
本网站主要提供:软件定制开发,网站定制开发,数据分析软件、管理软件、图片文件批量处理软件开发,软件产品发布及分享,软件开发资料收集及分享,计算机资料收集及分享,彩民工具开发资料收集及分享,生活资料收集及分享等。
常用网站:
百度
Google谷歌
搜狗
新浪
搜狐
腾迅
凤凰网
网易
京东商城
天猫
苏宁易购
汽车之家
淘宝网
东方财富
58同城
携程旅行
去哪儿
缤客酒店
4399游戏
爱奇艺
瓜子二手车
房天下
铁路购票12306
斗鱼TV
哔哩哔哩
访问本站表明您已同意以下条款:
1、本网站提供的资料、数据和软件仅供参考,请在使用前核实并慎重对待,因此受到的任何损失,精诚软件网不承担任何责任。
2、本网站提供的资料或数据有些来源于互联网,资料或数据的真实性、准确性等本网站不负任何责任,来源于互联网的资料或数据的版权归原创作者或原创网站所有。
3、本网站提供的软件仅为代替人工、提高效率、节省时间,严禁利用软件从事非法活动,对因使用软件而造成自身或他人损失的,均由软件使用者自行承担,本网站和软件作者不负任何责任。
版权所有 (C) 2025 精诚软件网 保留所有权利
版本 SanXin V3.5 11X5QianSan V3.0 11X5ShiYong ssqShiYong PK10ShiYong
温馨提示:市场有风险,投资需谨慎!!!