Arrays are often used in universities.AlgorithmExercise object. Some classic algorithms are very valuable, and they are useful for exams, installation, and interviews. But now is the Efficiency Era. programming focuses on production efficiency. using LINQ can makeProgramApe avoids writing some basic algorithms and focuses on business processing.
The following uses arrays as an example to describe some commonly used LINQ operations.
Static Void Main ( String [] ARGs ){ Int [] A = { 1 , 2 , 3 , 4 , 5 , 6 , 7 }; Int [] B = { 4 , 5 , 6 , 7 , 8 , 9 , 10 }; Int [] C = { 1 , 2 , 3 , 3 , 4 , 1 , 2 , 4 , 6 , 1 , 6 , 5 };
// Intersection VaR Fuck = A. Intersect (B );
// Union VaR Shit = A. Union (B );
// A does not have B VaR Diff1 = A. 0000t (B );
// B does not have VaR Diff2 = B. t ();
VaR Max = A. Max (); VaR Min = A. Min (); VaR AVG = A. Average (); VaR Dis = C. Distinct ();
Print (Fuck); print (shit); print (diff1); print (diff2); console. writeline (max); console. writeline (min); console. writeline (avg); print (DIS );
Console. readkey ();}
Private Static Void Print (ienumerable < Int > List ){ Foreach ( VaR Item In List) {console. Write (item + " " );} Console. writeline ();}
Copy code
There is a picture with the truth:
Some references:
Http://msdn.microsoft.com/zh-cn/library/bb397894.aspx
Http://msdn.microsoft.com/en-us/library/system.linq.enumerable.intersect.aspx
Original article: http://www.cnblogs.com/wyjexplorer/archive/2012/02/24/2366912.html