リストをパラメーターとして関数に送信したい。私はこのようなことをしたい:
public class SchoolClass
{
private int index = 0;
private string name = string.Empty;
private List<Student> students = new List<Student>();
public List<Student> Students
{
get { return students; }
set { students = value; }
}
public void AddStudent(string name, int age)
{
Student newStudent = new Student();
newStudent.Name = name;
newStudent.Age = age;
if (Students.Contains(newStudent))
{
Students.Add(newStudent);
Console.WriteLine(newStudent.ToString());
Console.ReadLine();
}
}
public void RemoveStudent(int studentId)
{
Student foundStudent = Students.Where(x => x.Id == studentId).FirstOrDefault();
if (foundStudent != null)
{
Students.Remove(foundStudent);
}
}
public void CheckIfClassEampty(List<Student> students) <----here
{
}
これを達成する最良の方法は何ですか?