Last active
May 26, 2021 15:55
-
-
Save Lahirutech/91f02fbc68406104e1460db9d7330f5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
List<int> intList = new List<int>() { 10, 20, 30, 40, 50 }; | |
Console.WriteLine("Method 1"); | |
//foreach with arrow function | |
intList.ForEach(num => Console.WriteLine(num)); | |
Console.WriteLine("Method 2"); | |
//using foreach | |
foreach (var el in intList) | |
Console.WriteLine(el); | |
Console.WriteLine("Method 3"); | |
//using for | |
for(int i =0; i < intList.Count; i++) | |
Console.WriteLine(intList[i]); | |
} | |
} | |
/* | |
Method 1 | |
10 | |
20 | |
30 | |
40 | |
50 | |
Method 2 | |
10 | |
20 | |
30 | |
40 | |
50 | |
Method 3 | |
10 | |
20 | |
30 | |
40 | |
50 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment