BOOL B1 = users. All (U = u.id = = 21); Determines whether the element satisfies the condition, or returns False if one is not satisfied, returns true
Any () bool B2 = users. Any (U = u.age = = 100); Returns true if there is a condition to be satisfied, otherwise, returns false
Double avgage = users. Average (U = u.age); The average of a property, not a string. Returned is a double
BOOL B3 = users. Contains (U1); Note: Only U1 has been added to users, and even if users have the same elements as U1, they do not contain
COUNT () int count = users. Count (U = u.age > 30); If there are no arguments, the value returns the number of rows of the collection directly, and if there is an expression, returns the number of satisfied conditions
List<user> users2=users. Concat (Users). ToList (); Splicing list and List2 and returning a new collection
List<user> Users3 = users2. Distinct (). ToList (); Removes duplicate elements, returns a new collection
User U4 = users. ElementAt (0)//effect equivalent to users[0] but if out of range, it will be an error
User U5 = users. Elementatordefault (1000); Similar to the previous method, but beyond that, no error will be returned, only the default value of that type will return
User U6 = users. Find (U = u.age >= 1000); Gets the first element that satisfies the condition, and returns the default value for the type if it is not found
List<user> USERS4 =users. FindAll (U = u.gender = = "female"); Gets all the elements that satisfy the condition, returning those elements to a new collection instead of the Findlastall ()
int index2 = users. FindIndex (3,5, u = u.age = = 22); Specifies the starting position and the end position, instead of the FindLastIndex ()
List<user> user5= users. GetRange (3, 4). ToList (); Gets the specified number of elements, starting at the specified position, to form a new collection
Users. Max (U = u.age); Users. Min (U = u.age); The smallest and the largest
var users6= users. GroupBy (U = u.gender). ToList (); Grouping, set of key-value pairs,
List<user> users7 = users. (U = u.id). ToList (); Sorts according to a column, and returns the new collection in reverse order: users. OrderByDescending (U = u.id). ToList ();
Users. RemoveAll (U = u.age < 30); Remove all elements that meet the criteria
Users. RemoveRange (2, 4); Deletes the specified number of elements starting at the specified position
Users. Reverse (); Reverses the collection, and if you specify where to invert it, users. Reverse (0, 3);
int sum = users. Sum (U = u.age); To sum a column
Users. Select (u=> new Hehe () {xxx=u.id, AAA = U.age}). ToList () to map elements from an existing collection to a new type you can also add a filtered LINQ statement directly on a later ToList
List<user> Users9 = users. (U = u.id). Skip (4). Take (3). ToList (); Skip () Skips multiple elements, take () is a selection of how many
List<user> users10= users. Where (u=>u.gender== "Male 1"). ToList (); Gets all the elements that meet the criteria and forms a new collection
Some LINQ methods, come on!!