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 }; Console.WriteLine(".Select - converting from array to enumerable"); IEnumerable<int> enumerable = array.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
JSON Seeder
cpp contact book
Immutable
AKASH B AND HIS CODES\\
Basma-1
Listiteration
true or false
Hzzz
Flipping a bit
SevenSevenSeven