[英]I have two Lists of string how can i create a string from each List index with the other one?
[英]I want to apply Except between two lists. One list is in MailAddress format and other is a String (Converted to list))
我想在兩個列表之間應用Except
。 一個列表是MailAddress
格式,另一個是String
(轉換為列表))?
List<MailAddress> toemails = new List<MailAddress>();
//List<String> emailsFrom = address.Split(';').ToList();
List<string> temp1 = new List<string>();
List<MailAddress> temp2 = new List<MailAddress>();
List<MailAddress> temp3 = new List<MailAddress>();
//message.to gives me a list of messages (outgoing)
foreach (var e in message.To)
{
temp2.Add(e);
}
//result contains a list of emails fetched (count=7)
var result = from lst in ListofEmails where lst.ToLower().Length < 50 select lst;
temp1 = result.ToList();
//(Not able to understand this, how to proceed)
// toemails = temp2.Except(temp1.);
// MailMessage msg = new MailMessage();
輸出, Except
結果,應該是MailAddress
對象的列表。
不需要使用Except,只需使用基本的LINQ:
由於temp1包含電子郵件地址......
toemails = temp2.Where(email =>
!temp1.Any(e => e.Equals(email.Address, StringComparison.OrdinalIgnoreCase))).ToList();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.