Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Enumerable
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int[] array = new [] { 1, 2, 3, 4 }; // тут какой то enumerable var preEnumerable = array.Select( i => GetSomeInt( i ) ); Console.WriteLine(".Select - converting from array to enumerable"); // тут enumerable, который делает Select из enumerable, то есть GetSomeInt вызовется и тут и там IEnumerable<int> enumerable = preEnumerable.Select( i => GetSomeInt( i ) ); DoWork( enumerable ); } public static void DoWork( IEnumerable<int> enumerable ) { Console.WriteLine("Checking for null"); if ( enumerable == null ) { return; } Console.WriteLine(".Contains when element exists"); bool isElementInEnumerable_True = enumerable.Contains( 3 ); Console.WriteLine(".Contains when element not exists"); bool isElementInEnumerable_False = enumerable.Contains( 65 ); Console.WriteLine(".FirstOrDefault when element exists"); int firstOrDefault = enumerable.FirstOrDefault( i => i == 3 ); } public static int GetSomeInt( int i ) { Console.WriteLine("i = " + i); return i; } } }
run
|
edit
|
history
|
help
0
Math v9.2
147
sdfgyutresdf
Battle System Algorythm
sdfghjtrefdc v
IEqatable simple object compare
V
Split string into equal chunks
Linear search vs. Binary search
Fórum ➡ Rotating a Square Matrix One Cell Counter Clockwise