Roll the dices app in Blazor (visual dices)
In this article I show you how to create a simple app in blazor where we throw two dices and display a message if the dices is a pair.
Blazor is a very strong framework to make both visual and logic coding. In this project you can see how easy it is to make a dice rolling app.
The following code is inside the Index.razor file in a Blazor Server App that is created in .NET 6.
Index.razor
By having the dice1 and dice2 variable we can simply use the Random class to get a random number between 1 and 6 and save it inside each dice variable.
We do only need the number because we can put that number inside the src of the image. In this case I created a "img" folder with all 6 images of all the sites of a dice.
Fell free to take these 6 dice images:
Fell free to expand the project and make it even cooler and smarter!