المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to remove null value from Lambda expression or Array



C# Programming
06-12-2012, 01:23 AM
Here is my code:

//Line below shows an email msg obj with To segment being an array (could have null to x number of receipients/emails):

emailMessage.EmailParamHeaders.To

//Below is creation of mail message obj:
MailMessage m = new MailMessage();

//Line blow is adding each To email address to the "m" object
emailMessage.EmailParamHeaders.To.ToArray().ToList().ForEach(x => m.To.Add(x));

How can I only add the elements of the array "To" where value is not null?

Thank you in advance.