没有合适的资源?快使用搜索试试~ 我知道了~
c# 中的arrlist queue HashtableTest SortedList stack 集合
需积分: 9 2 下载量 13 浏览量
2010-07-15
15:50:43
上传
评论
收藏 5KB TXT 举报
温馨提示
试读
6页
c# 中的arrlist queue HashtableTest SortedList stack 集合
资源推荐
资源详情
资源评论
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace arraylist
{
class Program
{
static void Main(string[] args)
{
ArrayList arrlist = new ArrayList();
arrlist.Add("苹果");//增加
arrlist.Add("香焦");
arrlist.Add("葡萄");
foreach (int n in new int[3] { 0, 1, 2 })
{
arrlist.Add(n);
}
arrlist.Remove(0);//移除值为0的数
arrlist.RemoveAt(3);//移除索引为3的数
arrlist.Insert(1, "apple");//在指定索引处插入数
for (int i = 0; i < arrlist.Count; i++)
{
Console.WriteLine(arrlist);
}
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace arraylist
{
class Program
{
static void Main(string[] args)
{
ArrayList arrlist = new ArrayList();
arrlist.Add("苹果");//增加
arrlist.Add("香焦");
arrlist.Add("葡萄");
foreach (int n in new int[3] { 0, 1, 2 })
{
arrlist.Add(n);
}
arrlist.Remove(0);//移除值为0的数
arrlist.RemoveAt(3);//移除索引为3的数
arrlist.Insert(1, "apple");//在指定索引处插入数
for (int i = 0; i < arrlist.Count; i++)
{
Console.WriteLine(arrlist);
}
Console.Read();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace HashtableTest
{
class Program
{
static void Main(string[] args)
{
Hashtable student = new Hashtable();
student.Add("001","Tom");//增加
student.Add("002", "Lily");
student.Add("003", "Jime");
student.Add("004", "Lucy");
foreach (DictionaryEntry element in student)
{
string di =element.Key .ToString ();
string name = element .Value .ToString ();
Console.WriteLine("学生的ID:{0} 学生的姓名 {1}",di,name );
}
student.Remove("003");
Console.WriteLine("删后遍历队:");
foreach (DictionaryEntry element in student)
{
string di = element.Key.ToString();
string name = element.Value.ToString();
Console.WriteLine("学生的ID:{0} 学生的姓名 {1}", di, name);
剩余5页未读,继续阅读
资源评论
wwfgu00ing
- 粉丝: 194
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功