var result = nomidb.Where(x => !listnamedataset.Contains(x.nome)).ToList();
i want to put all elements into a public list<nomierrati>nomisbagliati
. nomierrati is a class with properties id and nome. How can i put all elements in var result into nomisbagliati?
CodePudding user response:
When type of data contained in result
is different from nomisbagliati
, then what you can do is
nomisbagliati.AddRange(
result.Select(n => new nomierrati
{ id = n.id,
nome = n.nome
}));
Please consider I don't know almost anything about result
, so I'm just guessing...