I have created a class called studentRecord
, and it contains several properties such as Student Number, First Name, Last Name, Courses, and Credit Hours
for keeping track of individual student records. I also have created a list
called List<studentRecord> lstRecords = new List<studentRecord>();
that stores the various objects (students).
I understand adding a student
object through using lstRecords.Add();
, but am running in to trouble with editing the objects. The user is supposed to be able to enter a student number, and then be able to access and edit the properties of that specific instance of the object. I have come up with this code:
StudentRecord editRecord = lstRecords.Find(indexRecord =>
indexRecord.intStudentNumber == intChosenRecord);
(By the way, intChosenRecord
is a variable I declared to keep track of which index they are looking for)
I understand that StudentRecord
is declaring a new object of that type, and that editRecord
is my new object's name. However, I run into problems with using the .Find()
method. I realize that .Find()
searches through the list to find something that matches up with in input. Therefore, I assume that the intChosenRecord
is what the program is searching for.
However, I have no idea what indexRecord
is! This is the only time that it is used within the code, and I can change it to any name I want without errors. Could someone explain what this code does, and what indexRecord
is?