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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -