各位大哥大姐一定要救救小弟啊!!!
											先说明一下情况,唉,我们老师头两个周叫我们自学C#,然后让我们做一个在控制台实现txt文档的查询,添加,删除,修改的项目,我都做了两周了,每天的时间都用来写了,但我查询都还没写完啊!天啊,我们清明回来就要交了,各位大神一定要救救小弟啊,我不是在求代码,我是真的在求代码啊!我不是抄,我是借鉴啊,希望有注释的!小弟先谢谢各位大神了。										
					
	 2011-03-31 13:01
	    2011-03-31 13:01
  
 2011-03-31 13:39
	    2011-03-31 13:39
   2011-03-31 14:04
	    2011-03-31 14:04
   那对你来说太难了
那对你来说太难了 2011-03-31 14:39
	    2011-03-31 14:39
   程序代码:
程序代码:    class Student//新建一个学生类,包含学生的信息
    {
        public Student(string name, string no , string sex, int age)
        {
            this.Name = name;
            this.Age = age;
            this.Sex = sex;
            this.No = no;
        }
        public string Name { get; set; }//姓名
        public string No { get; set; }//学号
        public string Sex { get; set; }
        public int Age { get; set; }
    }
    class Students : CollectionBase//这是一个集合,为了方便的操作,当然也可以用泛型List<Student>
    {
        public Student this[int index] { get { return (Student)List[index]; } set { List[index] = value; } }
        public void Add(Student value)
        {
            this.List.Add(value);
        }
        public int IndexOfByName(string name)//用姓名查找
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i].Name == name)
                    return i;
            }
            return -1;
        }
        public int IndexOfByNo(string no)//用学号查找
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i].No == no)
                    return i;
            }
            return -1;
        }
        public void Insert(int index, Student value)//插入新记录
        {
            this.List.Insert(index, value);
        }
    }										
					
	 2011-03-31 14:51
	    2011-03-31 14:51
   程序代码:
程序代码:string[] lines = File.ReadAllLines("");//把文档按每行一条数据,读成一个数组
            Students ss = new Students();
            foreach (string l in lines)//循环访问每一行
            {
                if (!l.Contains("\t"))//不包含指定的分隔字符则跳到下一条,加这样一条可以很大程度上保证程序的运行
                    continue;
                string[] infos = l.Split('\t');//按指定的分隔字符把信息分配到数组中
                Student s = new Student(infos[0], infos[3], infos[4], int.Parse(infos[2]));//用相应的信息实例化Student
                ss.Add(s);//把s添加到集合中
            }										
					
	 2011-03-31 14:58
	    2011-03-31 14:58
   程序代码:
程序代码:int index = ss.IndexOfByName("张三");
            if (index == -1)
            {
                Console.Write("没有找到相应的信息");
            }
            else
            {
                Student s = ss[index];
                Console.Write("...");//想显示啥自己写,除了添加新记录,其它的都要先找到相应的数据再来操作
                //修改
                s.Name = "张四";
                s.No = "124123525";
                //删除
                ss.RemoveAt(index);
            }
 2011-03-31 15:03
	    2011-03-31 15:03
   2011-03-31 16:27
	    2011-03-31 16:27
   2011-03-31 16:28
	    2011-03-31 16:28
   2011-03-31 16:33
	    2011-03-31 16:33