Skip to content

Instantly share code, notes, and snippets.

@Lahirutech
Last active May 26, 2021 15:55
Show Gist options
  • Save Lahirutech/91f02fbc68406104e1460db9d7330f5d to your computer and use it in GitHub Desktop.
Save Lahirutech/91f02fbc68406104e1460db9d7330f5d to your computer and use it in GitHub Desktop.
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