Class
------
public class Student
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public static List<Student> GetStudents()
{
List<Student> students = new List<Student>();
students.Add(new Student { ID = 1,
FirstName = "A",
LastName = "F" });
students.Add(new Student { ID = 2,
FirstName = "B",
LastName = "G" });
students.Add(new Student { ID = 3,
FirstName = "C",
LastName = "H" });
return students;
}
}
Method Call
-----------
List<Student> studentList = Student.GetStudents();
Filter
----------
int idForFilter = 1
List<Student> studentFiltered = studentList.Where(c => c.ID == idForFilter ).ToList();
No comments:
Post a Comment