Horje
C# while loop Code Example
c# 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
}
while c#
int repeats = 0; 
bool while = true; //creates a bool variable with the true value
while (while = true) //repeats the code in the curly brackets as long
{                    //as the value in the round brackets remains true
   repeats++; //increase the value inside repeats
}
while c#
int i = 0; // initialization

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

    i++; // increment
}
do while loop in c#
do
{
    //code block


} while(condition);
c# 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));
C# while loop
int i = 1;
while(i != 0)
{
	//This code will loop
	Console.WriteLine("Say a number");
	i = int.Parse(Console.ReadLine());
}




Csharp

Related
C# .net JwtSecurityTokenHandler jwttoken claims to object Code Example C# .net JwtSecurityTokenHandler jwttoken claims to object Code Example
override GetHashCode Code Example override GetHashCode Code Example
serilog asp.net 5 Code Example serilog asp.net 5 Code Example
nuget package TSETMC guide Code Example nuget package TSETMC guide Code Example
decimal operator in Convert.toDouble() C# Code Example decimal operator in Convert.toDouble() C# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9