Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

C#, simple for loop

$
0
0

Hi!

 

Just out of curiosity, I'd like to know if there any way that in a single 'for loop', one statement can loop after the other completes the loop. Not that I know of.

 

Code Snippet:

 

using System;

class MainClass
{
    static void Main()
    {       
        for(int i=0; i<5; i++)
        {
            Console.WriteLine("Statement 1");
            Console.WriteLine("Statement 2");     
        }
    }
}

 

The output for the code snippet would be:

Statement 1
Statement 2
Statement 1
Statement 2

 

Is there any way that the Statement 2 can loop after the Statement 1 completes the loop like:

Statement 1
Statement 1

Statement 2

Statement 2

 

Thanks


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>