Hi @Polachan Paily ,
You can try to use the Enumerable.First() Method or LINQ Query to filter the data and get the first student.
Code like this:
List<Student> studentList = new List<Student>() {
new Student() { StudentID = 1, StudentName = "John"} ,
new Student() { StudentID = 2, StudentName = "Moin"} ,
new Student() { StudentID = 3, StudentName = "Bill"} ,
new Student() { StudentID = 4, StudentName = "Ram"} ,
new Student() { StudentID = 5, StudentName = "Ron"}
};
//use the first method.
Student firststudent = studentList.First();
//use the LINQ query
Student firststudent2 = studentList.Where(c => c.StudentID == 1).First();
//find the student by id.
List<Student> filterstudent = studentList.Where(c => c.StudentID == 1).ToList();
The result as below:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion