c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

how to use for loop in C#?

| | CSharp

For loop that needs to execute a specific number of times until a specified expression evaluates to false.


Syntax for for loop:


 for ( init; condition; increment )
{
statement(s);
}


class exampleforloop
{
static void Main()
{
for (int i = 1; i <= 5; i++)
{
Console.WriteLine(i);
}
}
}


Output:
1
2
3
4
5