Understanding break in foreach loop

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 335
Understanding break in foreach loop

var dnf = new List<string>() { "DotNet", "Funda", "Website" };
foreach (string name in dnf)
{
if (name == "Funda")
{
break;
}
Console.WriteLine(name);
}
Console.WriteLine("Rocks");


Output will be-
DotNet
Rocks

Thanks
Amatya

Comments or Responses

Login to post response