markjprice / cs11dotnet7

Repository for the Packt Publishing book titled "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
566 stars 206 forks source link

Outputting the generated numbers in "Generating random numbers for games and similar apps" #51

Closed MAS-OUD closed 1 year ago

MAS-OUD commented 1 year ago

on page 358, the code doesn't output anything. I suggest the code writes the generated random numbers to the console:

...
WriteLine($"dieRoll = {dieRoll}");

...
WriteLine($"randomReal = {randomReal}");

...
for (int i = 0; i < arrayOfBytes.Length; i++)
{
    WriteLine($"arrayOfBytes[{i}] = {arrayOfBytes[i]}");
}
markjprice commented 1 year ago

The code shown is supposed to be read, not entered, because the generated results are random so there's no point showing the output in the book because it will never look like what the reader sees. You only need to enter code when instructed to do so by numbered steps. Of course, readers are welcome to write any code they like and output anything they like.