C# : LINQ
Top 36 C# Example Pages...

[[".B(BCBCSTUUUUTTUUUUYF6767676F.BC/CSTTUUUUTTUUUU",".twee.","Any"," receives a Predicate. It determines if any element in a collection matches a certain condition. You could do this imperatively, using a loop construct. But the Any extension method provides another way. It reduces code size. ","Extension ","extension","Example."," Please include the System.Linq using directive at the top of your program. This allows you to call the Any extension. In this example, we see an array of three integer values. These values determine the results of the Any method. ","Int Array ","int-array","Methods: ","The first call tests for any even int. The second tests for any int greater than 3. The third checks for any int equal to 2.","Odd, Even ","odd","Tip: ","You can, when executing the program on your computer, change the expressions in the lambda to determine the correctness of the tests.","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","Based on:"," .NET 4.5\n\n","C# program that uses Any extension method","\n\nusing System;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n int[] array = { 1, 2, 3 };","\n // See if any elements are divisible by two.\n ","bool b1 = array.","Any","(item => item % 2 == 0);","\n // See if any elements are greater than three.\n ","bool b2 = array.","Any","(item => item > 3);","\n // See if any elements are 2.\n ","bool b3 = array.","Any","(item => item == 2);","\n // Write results.\n ","Console.WriteLine(b1);\n Console.WriteLine(b2);\n Console.WriteLine(b3);\n }\n}\n\n","Output","\n\nTrue\nFalse\nTrue","Internals."," How does the Any method actually work? When you call the Any method, you are passing a Predicate type, which is a function with a bool result. Internally, the Any method loops through each element in the source collection. ","Predicate ","predicate","Then: ","When it finds an element that the Predicate returns true for, the true result is propagated. It uses an early-exit.","Summary."," The Any method in the C# language doesn't do just anything. It instead evaluates a Predicate method on the source collection and returns a boolean indicating whether any element matches the Predicate. ","Thus: ","The Any method elegantly replaces imperative loop constructs. It reduces the size of source code.","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"],"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAABSCAMAAAAo0hXmAAAAGFBMVEX////3z8PzZ4v3sbf0k5r68N/xH2v157ja+sAcAAACl0lEQVR4Xu2awYqEMBAFp5Po/P8fLzPsQS2kNisNNtjXwFLte1NxwddxlnU/8f7M69bTD8zjy7zcmnkcmFsB5vU479uXI8DcUY4b1rlcodumEJtC37ocW85Wo9Cx7UOvUeixvUiiRqH3dShR6GWvilHh+j40uFcoxziYosD1jQIXsB1EUcB2QLxku+jjm1Nro8d7WZZ807EsM6LsY91N+2R1ik1DkYwcIFy2f2uSOcbKGcgKrUQJ4WAcd56w0M7cG3g3acmvH1CCgYCwoDFjCE0g1lIcLKVBka4wrx3Q8iQlBZRml0pMM7fxa4voTdohgUJfsuqU7doGOLY1CHnQEigenJSGsTjzCEQId3hl50136mxnjpMnxXJIyt4btmDCdljPzjgAEwSUhkteZO5eaAbqpuOJXN/OzBTVdiGllWxsy6n8hRmBzpvODuaZm1yFCHTedAwgg9kJaLr5kyRmBuqd4Yln48wk8nc7l62dUNyXmHno5hoTDoRrMpgtUJrOubhPEjMDtZR5Ir1JYIbtxHQ4EdsnMTNQ99navxPHwf4ZzAzUTecTmcwEVNPJYP8EZtjOTeczMplpOzOdDbZNYaa+QursE5nMtJ2ZbqYcOcysr5qO2zCIlspMTUAkZ4kozjuJmbaD6U6b7/vnMNN2dJ8Dca1MZtoOldTgpT6Xmd123UzX/pJ7JDLTdkNMh22k0AnMsN256bCN2C6JmbaLCdO57TKYabuBbP2NXtLIYN5dfVOmc9tdZfZCt9YmTCe2y2YOecmROstuOcwveZmUzKVDScwN3yTKf9z+g05n7lINiVxKlMO81Pgk0V//C4x4qsbnXAUGbigxeKcrMBWrUcB0j+ke0z2me6rxmC5lHtPFY7r/zWO6Hw5aZfXvwUh4AAAAAElFTkSuQmCC)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AA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