/** * The following are examples of how this method can be used: * With a lambda expression: * GetFloorsBy((floor) => floor.GetBuildingID() == building); * * With a anonymous delegate: * GetFloorsBy(delegate(Floor floor) { * return floor.GetBuildingID() == building; * }); * <param name="match"> Checks if the floors are the same, or not. </param> * <returns> This method returns all floors that match the delegate's conditions. </returns> */ public List<Floor> GetFloorsBy(FloorMatchDelegate match) { List<Floor> rtn = new List<Floor>(); foreach(Floor floor in this._floors) { if(match(floor)) { rtn.Add(floor); } } return rtn; }
/** * * The following are examples of how this method can be used: * With a lambda expression: * GetFloorBy((floor) => floor.GetBuildingID() == building); * * With a anonymous delegate: * GetFloorBy(delegate(Floor floor) { * return floor.GetBuildingID() == building; * }); * <param name="match"> Checks if the floors are the same, or not. </param> * <returns> This method returns the first floor that matches the delegate's conditions. </returns> */ public Floor GetFloorBy(FloorMatchDelegate match) { Floor rtn = null; foreach(Floor floor in this._floors) { if(match(floor)) { rtn = floor; } } return rtn; }