Home > Net >  How to find the List that some elements of the set
How to find the List that some elements of the set

Time:01-28

This is a class definition
Public class collection
{
Public string exceptionId;
Public string exceptionname;
}
//here judge whether there is a code, the code can be normal use, but do not need to use lambda expressions if use the Exits to see if elements exist?
If (a list. The Exists (TMP=& gt; TMP. ExceptionId====false)
id){
////added
The collection collection=new collection ();
Collection. ExceptionId=id;
Collection. Exceptionname=idname;
//list. Add (collection);
}
Parameters need Predicate Commissioned by the predicate
Don't know how to write back,
Meaning is the one in the list collection. The Id is consistent with the Id of the incoming parameters do not add to the list

Thank you very much!

CodePudding user response:

Their overloaded compare method, comparative object properties

CodePudding user response:

If (a list. The where (x=& gt; X.I d==id). ToList () Count> 0)

CodePudding user response:

Do not use lambda expressions, is how to do

CodePudding user response:

To the second floor

CodePudding user response:

ConcurrentDictionary
AddOrUpdate

CodePudding user response:

Var exist=list. Any (item=& gt; Item. ExceptionId==id);
If (exist)
{
//todo: if there is a logical
} the else
{
//todo: if there is no logical
}

CodePudding user response:

Sweat, need not lambda...
  •  Tags:  
  • C#
  • Related