新手提个问题,c#求最大值最小值,假设法,没法给min赋值 在case4

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace student
{
    public struct Student
    {
        public string Names;
        public double Src;
        public string Id;
    }
    class Program
    {
        public static Student[] students = new Student[20];//全局数组
        
        static void Main(string[] args)
        {
            int choes = 0;
            do
            {
                Console.WriteLine("************************************学生管理************************************");
                Console.WriteLine("1:注册学生信息 2:修改学生信息 3:查询学生信息 4:查询最高成绩/最低成绩 0:退出");
                Console.WriteLine("********************************************************************************");
                Console.WriteLine("请输入功能序号:");
                choes = int.Parse(Console.ReadLine());
                switch (choes)
                {
                    case 1:
                         int count = 0;
        Console.WriteLine("请输入学生姓名:");
                        students[count].Names = Console.ReadLine();
                        Console.WriteLine("请输入学生成绩:");
                        students[count].Src = double.Parse(Console.ReadLine());
                        students[count].Id = "2021" + new Random().Next(10,100).ToString();
                        Console.WriteLine("学号:{0},姓名:{1},成绩:{2},注册成功!", students[count].Id, students[count].Names, students[count].Src);
                        count++;
                        break;
                    case 2:
                        Console.WriteLine("输入修改学生的学号:");
                        string id2 = Console.ReadLine();
                        bool flag1 = true;
                        for (int i = 0; i <students.Length; i++)
                        {
                            if (id2==students[i].Id)
                            {
                                flag1 = false;
                                Console.WriteLine("输入新的成绩:");
                                students[i].Src = double.Parse(Console.ReadLine());
                                Console.WriteLine("修改成功! 学号:{0},姓名:{1},成绩:{2}",id2,students[i].Names, students[i].Src);
                            }

                        }
                        if (flag1)
                        {
                            Console.WriteLine("学号输入错误");
                        }

                        break;
                    case 3:
                        Console.WriteLine("请输入学生姓名:");
                        string name3 = Console.ReadLine();
                        Console.WriteLine("请输入学生学号:");
                        string id3 = Console.ReadLine();
                        bool flag3 = true;
                        for (int i = 0; i < students.Length; i++)
                        {
                            if (name3== students[i].Names&&id3== students[i].Id)
                            {
                                flag3 = false;
                                Console.WriteLine("学号:{0},姓名:{1},成绩:{2}", id3, students[i].Names, students[i].Src);
                            }
                        }
                        if (flag3)
                        {
                            Console.WriteLine("姓名或学号不正确");
                        }
                        break;
                    case 4:
                        Student max = students[0];
                        Student min = students[0];

                        for (int i = 0; i <students.Length; i++)
                        {
                            if (students[i].Src>max.Src)
                            {
                                max = students[i];
                            }
                            if (students[i].Src<min.Src)
                            {
                                min = students[i];
                            }
                        }
                        Console.WriteLine("最大值:{0}最小值{1}",max.Src,min.Src);
                        break;
                    case 0:
                        Console.WriteLine("欢迎下次使用,再见!");
                        break;
                    case 5:
                        foreach (Student item in students)
                        {
                            if (item.Names!=null)
                            {
                                Console.WriteLine("姓名\t成绩\t学号");
                                Console.WriteLine(item.Names + "\t" + item.Src + "\t" + item.Id);
                            }                       
                        }
                        break;
                    default:
                        Console.WriteLine("该功能不存在");
                        break;
                }
            } while (choes!=0);
        }
    }
}
 

首先 case1的int count定义错位置了(导致只给下标0添加学生),应该是全局变量才对
其次 判断大小时,因为使用的是结构体数组,int类型字段默认为0,导致判断条件成立,所以最小值一直是0,应当再做一次判断,判断该下标位置有没有学生

报什么错?

var min=new Student();