c# - Removing specific items in an Appointment List -


I have a list of calendar items that I have recovered using EWS:

 

Code> list & lt; Placement & gt; Apts = tApts.Items.ToList & lt; Placement & gt; ();

I am trying to remove all the appointments in the list, which is a topic in which "cancel" at the beginning of the title:

  apts RemoveAll (apt = & gt; apt.Subject.StartsWith ("Canceled:"));  

This is throwing me a "object is not set for an instance of reference object."} System.Exception {System.NullReferenceException} .

I am assuming that this is happening because the appointment topic is zero.

However this is my solution:

  foreach (Appointment apt in appetts) {if (Apt.Subject == zero) released; If (apt.Subject.StartsWith ("Canceled:")) apts.Remove (apt); }  

However this also throws an error because I am changing the size of the list, while I am turning it on again.

What will be the best way to get rid of all items whose topics start with "canceled" even if this topic is meaningless.

"post-text" itemprop = "text">

You can check that topic is property null in your lambda expression:

  apts.RemoveAll (apt = & gt; apt.Subject! = Null & amp; amp; APT. With Shabank. Start ("Canceled:"));  

Comments