I have the following code: it is not complete yet but i want to know how to access members in the class with a foreach statement as indicated by the comment in code. I suspect the answer is simple and I’m just not seeing it. Can anyone help me?
public class PassengerList : List<Passenger>
{
public bool CheckRules()
{
}
private bool DaughtersNotWithFather()
{
foreach (Passenger p in ???)// how do i access list members in this class with this foreach statment?
{ // do stuff }
}
}
Instance of your class is a
List<Passanger>(which is enumerable). So, just refer your class viathiskeyword