I have this code
My question that I wanna use this " SinhVien sv " in forEach
instead of using SinhVien s.
I do not use "SinhVien s" for printing the student on the list that I need to find.
Thanks for reading and helping me, have a nice day!!
Code:
class QuanLySinhVien
{
public static List<SinhVien> DanhSachSinhVien = new List<SinhVien>(50);
public List<SinhVien> GetDanhSachSinhVien
{
get => DanhSachSinhVien;
}
public void FindStudent()
{
Console.Write("Enter ID's student that you need to find: ");
string msSV = Console.ReadLine().ToUpper();
SinhVien sv = CheckExist(msSV);
if (sv == null)
{
Console.Write("Can not find this student with {0}'s ID\n", msSV);
}
else
{
foreach (SinhVien s in QuanLySinhVien.DanhSachSinhVien)
{
Console.WriteLine("ID: " + sv.MMaSV);
Console.WriteLine("Name: " + sv.HoTen1);
Console.WriteLine("Birthdate: ");
sv.NgaySinh1.ShowBirthdate();
Console.WriteLine("Address: " + sv.DiaChi1);
Console.WriteLine("Number: " + sv.DienThoai1);
Console.WriteLine("------*****------");
break;
}
}
}
}
Code:
foreach (SinhVien s in QuanLySinhVien.DanhSachSinhVien) }
I do not use "SinhVien s" for printing the student on the list that I need to find.
Thanks for reading and helping me, have a nice day!!
Comment