ASP.Net/Language Basics/Do While

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Do while loop (C#)

<%@ 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! <br>";
            }
            bytRollCounter +=1;
            DiceRoll = Convert.ToInt32(objRandom.Next(6)) + 1;
            Message1.Text += "Rolled a: " + DiceRoll + "<br />";
        }
    }
</script>
<html>
<head>
    <title>Do...While Loop Example</title>
</head>
<body>
    <asp:Label id="Message1" runat="server"></asp:Label>
</body>
</html>