我正在尝试使用LINQ删除列表的所有引用,其中两个属性的组合等于字符串.
例如:我有对象
class obj
{
string a;
string b;
}
Run Code Online (Sandbox Code Playgroud)
我有一个单独的字符串x
所以我想删除哪里 (a+b) == x
以下是我想要做的例子:
void Main()
{
List<telefone> phones = new List<telefone>()
{
new telefone()
{
ddd = "21", numero="1234"
},
new telefone()
{
ddd = "22",
numero="1234"
}
};
List<string> newPhones = new List<string>(){"1151814088", "11996081170", "098", "890", "99988", "6533"};
for(int i = 0; i < newPhones.Count; i++)
{
phones.Select(x => x.ddd + x.numero).ToList().RemoveAll(x => (x == phones[i]));
}
phones.Dump();
}
public class telefone
{
//[System.Xml.Serialization.XmlIgnore]
internal string …Run Code Online (Sandbox Code Playgroud)