jeudi 25 avril 2019

How to check for the existence of an object's property inside an "if" condition statement

I have a list of objects of type ROUTE.

Each ROUTE object contains string properties, but some objects do not contain the EXITSIGNAL property (doesn't exist not null)

some of code :

List<ROUTE> SelectedRoutes = new List<ROUTE>();
foreach (var route in XmlData.ROUTES)
{
   if (sig.SignalID.Equals(route.ENTRANCESIGNAL) &&
       sig.SignalDIRECTION.Equals(route.DIRECTION) &&                     
       "Condition on EXITSIGNAL property")
   {
       SelectedRoutes.Add(route);
   }
}

How to add a third condition that allows me to choose only objects that contain this property "EXITSIGNAL"

Aucun commentaire:

Enregistrer un commentaire