Discovering Blazor: a small dice rolling page

using System;
namespace DiceBlazorApp
{
public class Dice
{
private Random rand = new Random();
public int RollDice()
{
int currentRoll = rand.Next(1,7);
return currentRoll;
}
}
}
@page "/dice"<h3>DiceRoller</h3><p>@currentRoll</p><button class="btn btn-primary" @onclick="RollDice">Roll the dice!</button>@code {
private int currentRoll = 0;
Dice d = new Dice();
private void RollDice()
{
currentRoll = d.RollDice();
}
}
<li class="nav-item px-3">
<NavLink class="nav-link" href="dice">
<span class="oi oi-plus" aria-hidden="true"></span> Dice
</NavLink>
</li>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store