哪位C#大神能帮忙看下??

来源:百度知道 编辑:UC知道 时间:2024/05/28 16:13:40
C#大神啊~小弟是个C#初学者。做了个C#语言写的学生信息管理系统。想把功能完善下,改成无限循环查询,然后按Esc键就能退出程序的,但是不管怎么改都改不对。各位大神如果知道怎么改能不能看看怎么改?帮忙写下啊!!代码如下:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrStructEnum
{
struct Student//定义Student结构类型
{
public string sNum;//学号
public string sName;//姓名
public float sScore;//成绩
Student[] stu = new Student[4];//声明学生数组变量来存放多个学生的信息
for (int i = 0; i < stu.Length; i++)//for循环实现多个学生信息的录入
{
Console.WriteLine("please input “+(i+1)+”th information");
Console.WriteLine("please input sNum");//输出提示信息
stu[i].sNum = Console.ReadLine();//为数组的当前数据元素的sNum赋值
Console.WriteLine("please input sName");
stu[i].sName = Console.ReadLine();//为数组的当前数据元素的sName赋值
Console.WriteLine("

你写得很乱
首先 Student类型定义未结束
struct Student//定义Student结构类型
{
public string sNum;//学号
public string sName;//姓名
public float sScore;//成绩
这里少大括号

第二
你采用的是控制台,程序代码没有放到Main函数中

static void Main(string[] args)
{
这里写你主程序
}

第三
控制台不响应 撤销键以外的键盘事件
撤销键 ctrl + c
使用 Esc键参考下面
static void Main(string[] args)
{
int i = 0;
while (true)
{
if (Console.KeyAvailable)
{
ConsoleKeyInfo InPutKey = Console.ReadKey();
if (InPutKey.Key == ConsoleKey.Escape)
{
break;
}
}

i += 1;
Console.WriteLine(i);//你的代码