do while loop in csharp

Code Example - do while loop in csharp

                
                        do
{
    //code block


} while(condition);
                    
                
 

csharp while true loop

                        
                                while (true)//the "true" keyword mean it will run forever, you can change it too (example while (i > 3))
{
	//Code here
    System.Threading.Thread.Sleep(100) // Convertion: 1000 = 1 second
    //if you are using a while true statment, your program will frezze without this Sleep keyword
}
                            
                        
 

csharp while loop

                        
                                int i = 1;
while(i != 0)
{
	//This code will loop
	Console.WriteLine("Say a number");
	i = int.Parse(Console.ReadLine());
}
                            
                        
 

while csharp

                        
                                int i = 0; // initialization

while (i < 10) // condition
{
    Console.WriteLine("i = {0}", i);

    i++; // increment
}
                            
                        
 

csharp do while or

                        
                                int sugar = 0;
int salt = 0;

do {
    bottle1.choose();
    bottle2.choose();
    if ((bottle1 == 'Sugar') && (bottle2 == 'Sugar'))
    {
        Console.Write("Sugar");
        sugar++;
    }
    else if ((bottle1 == 'Salt') && (bottle1 == 'Salt'))
    {
        salt++;
        Console.Write("Salt");
    }
    else
    {
        Console.Write("None");
    }
} while ((salt < 10) || (sugar < 10));