声明:本人大学生,技术能力不高,不喜勿喷,请以学习的态度看帖。
来源:互联网 发布:linux安装git服务器 编辑:程序博客网 时间:2024/05/21 21:45
我去前面探探路———提莫队长
不多说上代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections; //添加上这个命名空间
namespace ArrayList类使用
{
class Program
{
static void Main(string[] args)
{
ArrayList myArryList = new ArrayList(5); //集合实例化
Console.WriteLine("myArrayList初始化之后有{0}个元素",myArryList .Count );
//Add方法用于向集合添加元素,且每次只添加一个元素
myArryList.Add(12346);
myArryList.Add('a');
myArryList.Add("mystring");
myArryList.Add(25.63);
myArryList.Add(10L);
Console.WriteLine("使用Add方法添加5个元素后有{0}个元素",myArryList .Count );
string[] mystringArray = { "张三", "李四", "小明", "小红" }; //实例化
myArryList.AddRange(mystringArray);
Console.WriteLine("使用AddRange方法后有{0}个元素",myArryList .Count );
//引用类型string object类是所有类型的基类
//遍历集合元素
foreach (object outelement in myArryList)
{
Console.WriteLine(outelement + "\t");
}
Console.WriteLine("====================================");
Console.WriteLine("====================================");
Console.WriteLine("现在删除元素");
[color=#00FF00] //删除元素有4种方法
//使用变量名.Remove(值) 值为集合中元素名 作用删除本元素
// .RemoveAt(值) 值为数字 作用删除第几个元素
// .RemovRange(值,值) 值为数字 作用从第几个开始删除几个
// .Clear 作用清除所有元素[/color]
Console.ReadKey();
}
}
不多说上代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections; //添加上这个命名空间
namespace ArrayList类使用
{
class Program
{
static void Main(string[] args)
{
ArrayList myArryList = new ArrayList(5); //集合实例化
Console.WriteLine("myArrayList初始化之后有{0}个元素",myArryList .Count );
//Add方法用于向集合添加元素,且每次只添加一个元素
myArryList.Add(12346);
myArryList.Add('a');
myArryList.Add("mystring");
myArryList.Add(25.63);
myArryList.Add(10L);
Console.WriteLine("使用Add方法添加5个元素后有{0}个元素",myArryList .Count );
string[] mystringArray = { "张三", "李四", "小明", "小红" }; //实例化
myArryList.AddRange(mystringArray);
Console.WriteLine("使用AddRange方法后有{0}个元素",myArryList .Count );
//引用类型string object类是所有类型的基类
//遍历集合元素
foreach (object outelement in myArryList)
{
Console.WriteLine(outelement + "\t");
}
Console.WriteLine("====================================");
Console.WriteLine("====================================");
Console.WriteLine("现在删除元素");
[color=#00FF00] //删除元素有4种方法
//使用变量名.Remove(值) 值为集合中元素名 作用删除本元素
// .RemoveAt(值) 值为数字 作用删除第几个元素
// .RemovRange(值,值) 值为数字 作用从第几个开始删除几个
// .Clear 作用清除所有元素[/color]
Console.ReadKey();
}
}
}
后续我会不定时发博客
阅读全文
0 0
- 声明:本人大学生,技术能力不高,不喜勿喷,请以学习的态度看帖。
- 以端正的态度学习业务知识
- 学习C++编程之前的声明-------请不要看《C++变成死相》
- 大学生如何突破学习能力
- 学习能力和工作态度是准绳
- 学习能力和工作态度是准绳
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 对技术的态度
- 做技术的态度
- 04-基本的增删改查
- 实战java高并发程序设计读书笔记:java 线程池
- jsp总结2
- JDK8-并行流与串行流(七)
- 终于等到你 -- 北京理工大学考研复试小记
- 声明:本人大学生,技术能力不高,不喜勿喷,请以学习的态度看帖。
- JSP状态管理
- 博客入坑。。。
- Java数据结构算法实现
- python捕获ctrl+c手工中断程序的两种方法
- NIO学习笔记——缓冲区(Buffer)详解
- 枚举
- javaWeb项目之简析配置文件
- 设计模式——组合模式