c# - How do I Find an object up the list I am iterating through -
i iterating through list of objects of type "prvemployeeincident".
the object has following properties:
public datetime dateofincident { get; set; } public bool iscountedasapoint; public decimal originalpointvalue; public bool isfirstincollection { get; set; } public bool islastincollection { get; set; } public int positionincollection { get; set; } public int daysuntilnextpoint { get; set; } public datetime datedroppedbysystem { get; set; } public bool isgoodbehaviorobject { get; set; }
my list sorted dateofincident property. find next object up list iscounted == true , change iscounted = false.
one question:
1) how find object list ?
if understand question correctly, can use linq firstordefault
:
var nextobject = list.firstordefault(x => x.iscountedasapoint); if (nextobject != null) nextobject.iscountedasapoint = false;
Comments
Post a Comment