ASP.Net/Language Basics/Do While
Do while loop (C#)
<source lang="csharp">
<%@ Page Language="c#" %> <script runat="server">
void Page_load() { Random objRandom = new Random(); int DiceRoll = 0; byte bytRollCounter = 0; while (DiceRoll != 6){ if(bytRollCounter%3 == 0 && !(bytRollCounter==0)){ Message1.Text += " Keep trying!
"; } bytRollCounter +=1; DiceRoll = Convert.ToInt32(objRandom.Next(6)) + 1; Message1.Text += "Rolled a: " + DiceRoll + "
"; } }
</script> <html> <head>
<title>Do...While Loop Example</title>
</head> <body>
<asp:Label id="Message1" runat="server"></asp:Label>
</body> </html>
</source>