Answers for "foreach() c#"

C#
35

foreach syntax c#

var fibNumbers = new List<int> { 0, 1, 1, 2, 3, 5, 8, 13 };
int count = 0;
foreach (int element in fibNumbers)
{
    count++;
    Console.WriteLine($"Element #{count}: {element}");
}
Console.WriteLine($"Number of elements: {count}");
Posted by: Guest on January-18-2020
1

c# list foreach

someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); });
Posted by: Guest on August-11-2020
1

c# list.foreach

List<string> someList = <some way to init>
someList.ForEach(delegate(string s) {
    <process the string>
});
Posted by: Guest on May-28-2020

C# Answers by Framework

Browse Popular Code Answers by Language