C#控制台实现模拟学生管理系统.doc

上传人:汽*** 文档编号:543490180 上传时间:2023-03-02 格式:DOC 页数:5 大小:148.51KB
返回 下载 相关 举报
C#控制台实现模拟学生管理系统.doc_第1页
第1页 / 共5页
C#控制台实现模拟学生管理系统.doc_第2页
第2页 / 共5页
C#控制台实现模拟学生管理系统.doc_第3页
第3页 / 共5页
C#控制台实现模拟学生管理系统.doc_第4页
第4页 / 共5页
C#控制台实现模拟学生管理系统.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《C#控制台实现模拟学生管理系统.doc》由会员分享,可在线阅读,更多相关《C#控制台实现模拟学生管理系统.doc(5页珍藏版)》请在金锄头文库上搜索。

1、C#控制台模拟学生管理系统最终运行效果添加学生删除学生修改学生代码如下using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace SGMS class Program static void Main(string args) List lstStudent = new List(); bool flag = true; while (flag) Console.WriteLine(-); Console.ForegroundColor = ConsoleColor.Re

2、d; Console.WriteLine(使用提示(按键-操作):A-添加 D-删除 C-修改 L-查看); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(-); ConsoleKey ck = Console.ReadKey(true).Key; switch (ck) case ConsoleKey.A: /Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(请输入学生相关信息); /Console.ForegroundColor = Co

3、nsoleColor.Gray; Student stu = new Student(); Console.Write(学号:); stu.stuNo = Console.ReadLine().Trim(); Console.Write(姓名:); stu.stuName = Console.ReadLine().Trim(); Console.Write(性别:); stu.stuSex = char.Parse(Console.ReadLine().Trim(); Console.Write(年龄:); stu.stuAge = short.Parse(Console.ReadLine()

4、.Trim(); lstStudent.Add(stu); Console.WriteLine(添加成功); break; case ConsoleKey.D: if (lstStudent.Count = 0) Console.WriteLine(系统还未添加任何学生信息); else Console.Write(请输入要删除的学生的学号:); string no = Console.ReadLine().Trim(); for (int i = 0; i lstStudent.Count; i+) if (lstStudenti.stuNo = no) lstStudent.Remove(

5、lstStudenti); Console.WriteLine(删除成功); break; if (i = lstStudent.Count - 1) Console.WriteLine(抱歉!系统中没有这个学号); break; case ConsoleKey.C: if (lstStudent.Count = 0) Console.WriteLine(系统还未添加任何学生信息); else Console.Write(请输入要修改的学生的学号:); string no = Console.ReadLine().Trim() ; for (int i = 0; i lstStudent.Co

6、unt; i+) Student item = lstStudenti; if (item.stuNo = no) Console.Write(学号:); item.stuNo = Console.ReadLine().Trim(); Console.Write(姓名:); item.stuName = Console.ReadLine().Trim(); Console.Write(性别:); item.stuSex = char.Parse(Console.ReadLine().Trim(); Console.Write(年龄:); item.stuAge = short.Parse(Console.ReadLine().Trim(); lstStudenti = item; Console.WriteLine(修改成功!); break; if (i = lstStudent.Count - 1) Console.WriteLine(抱歉!系统中没有这个学号); break; case ConsoleKey.L: if (lstStudent.Count = 0)

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号