I have this code:
List<Visibility> ListVisibility = new List<Visibility>();
public class Visibility
{
public int ShpNo;
public int QtyShp;
public int NumPallets;
public string ETA;
}
Visibility item = ListVisibility.Find(VisibItem => VisibItem.ETA == e.Day.Date.ToShortDateString());
But the above Find is not returning any Item, when there is an item that matches that condition.
What could be wrong here?
Most likely string match does not find a match. Change code to compare dates as
Dateportions ofDateTimeand it will have better chance to work.Sample is assuming
e.DayisDateTime. Also you may need to handle “item.ETAis not valid date/empty” case (i.e. by usingDateTime.TryParse) to match original behavior.