list泛型的使用

          ArrayList list = new ArrayList();
ArrayList list = new ArrayList(); //可变数组
list.Add("我"); //Add 添加 向数组中赋值索引为最末尾
list.Add("今年");
list.Add("");
list.Add("岁了");
list.Add("");
list.Add("岁了");
list.Add("");
list.Add("岁了"); 知识点
list.Contains();//查询数组中元素是否存在
list.CopyTo(); //赋值数组中的全部数据
list.RemoveAt();//根据索引把指定位置元素删除
list.Remove(); //移除的是元素
list.Clear();//清空数组
list.Count; //数组元素的个数 举例子
bool result = list.Contains("我"); //返回bool 查询数组中元素是否存在 string[] list1 = new String[];
list.CopyTo(list1); //赋值数组中的全部数据 赋值的集合的数据类型要一致 oblect[] list1 = new oblect[];
list.CopyTo(list1); //赋值数组中的全部数据 赋值的集合的数据类型可以不一致 list.RemoveAt(); //把第七个元素移除
list.Remove("我"); //移除的是元素 int index=list.Count;
Console.WriteLine(index); Console.WriteLine(list[]); foreach (object val in list)
{
Console.WriteLine(val);
}
Console.ReadKey();
#endregion #region 泛型集合
List<int> intList=new List<int>(); //List泛型集合 类型是一致的
intList.Add();
intList.Add();
intList.Add();
int result = intList.IndexOf();//根据元素,查找返回该元素的索引位置,如果没有,返回-1 可以指定索引范围(34,0,2) //知识点
intList.Add();//查询数组中元素是否存在
intList.CopyTo(); //赋值数组中的全部数据
intList.RemoveAt();//根据索引把指定位置元素删除
intList.Remove(); //移除的是元素
intList.IndexOf(); //根据元素,查找返回该元素的索引位置,如果没有,返回-1
intList.Insert(,);//将元素插入集合某处 //举例子
intList[] = ;
intList.Insert(,);//将元素插入集合某处 原来索引位置的元素值自动下移,整理向后移动
Console.WriteLine(intList[]);
Console.ReadKey();
#endregion #region 泛型数组练习
List<string> arrList=new List<string>();
arrList.Add("张三");
arrList.Add("年龄");
arrList.Add("身高");
arrList.Add("电话号码");
int a = arrList.Count;
string name = "";
for (int i = ; i < arrList.Count; i++)
{
if(arrList[].Equals("张三"))
{
arrList[] += "今年的";
Console.WriteLine(arrList[]);
}
}
Console.ReadKey();

本系列教程:

C#基础总结之八面向对象知识点总结-继承与多态-接口-http://www.cnblogs.com/spring_wang/p/6113531.html

C#基础总结之七面向对象知识点总结1http://www.cnblogs.com/spring_wang/p/6113526.html

C#基础总结之六 DataTable (临时表/数据源) 和Datatable 名片练习http://www.cnblogs.com/spring_wang/p/6113520.html

C#基础总结之五Dictionary<string, string[]>和while循环http://www.cnblogs.com/spring_wang/p/6113514.html

C#基础总结之四List-Hashtable-冒泡排序http://www.cnblogs.com/spring_wang/p/6113504.html

C#基础总结之三循环控制-for-数组-乘法表-arraylisthttp://www.cnblogs.com/spring_wang/p/6113496.html

C#基础总结之二循环控制-运算符http://www.cnblogs.com/spring_wang/p/6113484.html

C#基础总结之一变量常量-if嵌套语句-witch结构-类型转换http://www.cnblogs.com/spring_wang/p/6113476.html

C#基础课程之六(临时表)DataTable使用方法http://www.cnblogs.com/spring_wang/p/6113454.html

C#基础课程之五集合(HashTable,Dictionary)http://www.cnblogs.com/spring_wang/p/6113404.html

C#基础课程之四集合(ArrayList、List<泛型>)http://www.cnblogs.com/spring_wang/p/6113396.html

C#基础课程之三循环语句http://www.cnblogs.com/spring_wang/p/6113383.html

C#基础课程之二变量常量及流程控制http://www.cnblogs.com/spring_wang/p/6113372.html

C#基础课程之一注释和控制台、一些常识http://www.cnblogs.com/spring_wang/p/6113361.html

C#基础第九天-作业答案-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113291.html

C#基础第九天-作业-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113285.html

C#基础第八天-作业答案-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113274.html

C#基础第八天-作业-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113258.html

C#基础第七天-作业答案-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113232.html

C#基础第七天-作业-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113224.html

C#基础第六天-作业-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113028.html

C#基础第六天-作业答案-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113033.html

C#基础第五天-作业答案-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113022.html

C#基础第五天-作业-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113013.html

C#基础第四天-作业答案-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113005.html

C#基础第四天-作业-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113000.html

C#基础第三天-作业答案-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112888.html

C#基础第三天-作业-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112885.html

C#基础第二天-作业答案-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112881.html

C#基础第二天-作业-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112875.html

C#基础第一天-作业答案http://www.cnblogs.com/spring_wang/p/6112872.html

C#基础第一天-作业http://www.cnblogs.com/spring_wang/p/6112867.html

C#-string.Format对C#字符串格式化http://www.cnblogs.com/spring_wang/p/6077098.html

C#基础课程之四集合(ArrayList、List<泛型>)的更多相关文章

  1. C#基础课程之五集合(HashTable,Dictionary)

    HashTable例子: #region HashTable #region Add Hashtable hashTable = new Hashtable(); Hashtable hashTabl ...

  2. SQL基础--查询之四--集合查询

    SQL基础--查询之四--集合查询

  3. Java基础系列 - JAVA集合ArrayList,Vector,HashMap,HashTable等使用

    package com.test4; import java.util.*; /** * JAVA集合ArrayList,Vector,HashMap,HashTable等使用 */ public c ...

  4. C#集合ArrayList、泛型集合List(3)

    数组的制约:局限性.有多少放多少,要想追加,就必须重新再定义一个数组,这就造成了资源的极大浪费而且性能消耗也比较大.因此此操作不太推荐.所以集合就来了. ,,,} 创建集合: ArrayList li ...

  5. C#基础总结之四List-Hashtable-冒泡排序

    #region 第四天作业 名片--------ArrayList //ArrayList card = new ArrayList(); //card.Add("2202111001122 ...

  6. C#基础课程之六(临时表)DataTable使用方法

    DataTable 用法:赋取值操作,及报错情况 dataTable.Columns.Add("Name"); //Columns 对象获取该集合的全部列,添加列名. 默认stri ...

  7. C#基础课程之三循环语句

    for循环: ; i < ; i++) { Console.WriteLine("执行"+i+"次"); } while循环: while (true) ...

  8. C#基础课程之一注释和控制台、一些常识

    注释是程序员对代码的说明,以使程序具有可读性.源代码在编译的过程中,编译器会忽略其注释部分的内容. ()行注释 格式为:// 注释内容 用两个斜杠表示注释的开始,直到该行的结尾注释结束. ()块注释 ...

  9. 第三章泛型集合ArrayList 和Hashtable

    第三章泛型集集合 ArrayList 变量名 = new ArrayList();  //相当与一个容器 他的执行using 是  using System.Collections; 变量名.ADD( ...

随机推荐

  1. Git之第三方托管oschina

    一.git 简介 1.Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. 2.Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理. ...

  2. 【MongoDB:】稍微复杂的操作

    1:插入数据稍微复杂的形式 doc=( {"user_id" : "ABCDBWN", "password" :"ABCDBWN& ...

  3. Webview跨域访问风险

    漏洞原理:WebView对象的行为是通过WebSettings类进行设置的,如果配置不当,攻击者就可以利用该漏洞可以打破Android沙盒隔离机制,从而通过某个应用来攻击其它应用,盗取其它应用本地保存 ...

  4. idea 配置svn

        1.情景展示 idea安装好后,如何配置svn? 2.分析 由于没有针对idea的svn插件,因此只能选择安装svn的客户端. 3.解决方案 第一步:下载小乌龟SVN客户端: 官网地址:htt ...

  5. ppt整体配色方案

        背景色建议以灰色或者被色为主.       在百度云盘也有大量的ppt模板,还是非常不错的.http://pan.baidu.com/s/1bpDf7Fh    

  6. jquery利用appendTo动态创建元素

    动态创建元素可以说是DOM中常做的事情,下面我来介绍在jquery中利用appendTo来动态创建元素,有需要的朋友可参考参考. 当HTML字符串是没有属性的元素是, 内部使用document.cre ...

  7. Ubuntu18.04中配置QT5.11开发环境

    准备工作 参考 https://wiki.qt.io/Install_Qt_5_on_Ubuntu . # 安装g++ sudo apt install build-essential # sudo ...

  8. 基于Echarts的中国地图数据展示

    发布时间:2018-10-31   技术:javascript+html5+canvas   概述 基于echarts的大数据中国地图展示,结合API定制,开发样式,监听鼠标事件,实现带参数路由跳转等 ...

  9. 俄罗斯方块-C语言-详注版

    代码地址如下:http://www.demodashi.com/demo/14818.html 俄罗斯方块-C语言-详注版 概述 本文详述了C语言版俄罗斯方块游戏的原理以及实现方法,对游戏代码进行了详 ...

  10. 【php】分享一个php转换微信、QQ、微博 特殊非主流 | 杀马特 网名的 function

    1.实现的效果: 2.将上面带有图标.非主流的文字,转换成utf-8格式,能存进去和读出来. 3.code: function emoji_encode($nickname){ $strEncode ...