ArrayList1
来源:互联网 发布:学java web看什么书 编辑:程序博客网 时间:2024/06/07 22:38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ArrayList1
{
//创建一个学生类
class Student
{
/// <summary>
/// 无参构造函数
/// </summary>
public Student()
{ }
/// <summary>
/// 有参构造函数
/// </summary>
/// <param name="name"></param>
/// <param name="age"></param>
public Student(string name, int age)
{
this.name = name;
this.age = age;
}
/// <summary>
/// 姓名
/// </summary>
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// 年龄
/// </summary>
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
}
class Program
{
static void Main(string[] args)
{
//创建几个学生
Student xyy = new Student("小月月", 18);
Student fj = new Student("凤姐", 18);
Student fr = new Student("芙蓉姐姐", 18);
Student xl = new Student("犀利哥", 18);
//创建一个集合
ArrayList al = new ArrayList();
//将创建的学生添加到集合中
al.Add(xyy);
al.Add(fj);
al.Add(fr);
al.Add(xl);
//遍历集合中的学生
//foreach (object item in al)
//{
// Student student = item as Student;
// if (student != null)
// {
// Console.WriteLine(student.Name);
// }
//}
al.RemoveAt(0);
for (int i = 0; i < al.Count; i++)
{
Student student = al[i] as Student;
Console.WriteLine(student.Name);
Console.WriteLine(student.Age);
}
Console.Read();
}
}
}
- ArrayList1
- ArrayList1.8 源码
- VC++编程实现镜像劫持
- 转:驱动开发函数IoCreateDevice /IoCreateSymbolicLink / IoDeleteDevice
- Hello World,一个简单的JSR 168 portlet
- linux下常用网络命令
- Maven项目不打包*.hbm.xml文件
- ArrayList1
- 两分钟彻底让你明白Android Activity生命周期(图文)!
- qt资源
- 实用的wordpress全站搜索替换插件search-and-replace中文版
- android webview onJsAlert只调用一次的问题
- 史诗乐推荐
- maven经验之谈(一)
- 生成的Dll突然变小的解决方法
- IOS开发学习笔记-----UILabel 详解