Right-Click on project,
[Add]
[Reference...]
System.Windows.Forms
C# problem with System.Windows.Forms console application
Stefanos Tsitmidelis
21
Reputation points
using System;
using System.Windows.Forms;
class RandomInt
{
// main entry point for application
static void Main(string[] args)
{
int value;
string output = "";
Random randomInteger = new Random();
// loop times
for (int i = 1; i <= 20; i++)
{
// pick random integer between 1 and 6
value = randomInteger.Next(1, 7);
output += value + " "; // append value to output
// if counter divisible by 5, append newline
if (i % 5 == 0)
output += "\n";
} // end for structure
MessageBox.Show(output,
"Random Numbers from 1 to 6",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
} // end Main
} // end class RandomInt
Accepted answer
-
Castorix31 81,461 Reputation points
2021-04-07T06:06:10.163+00:00
1 additional answer
Sort by: Most helpful
-
Stefanos Tsitmidelis 21 Reputation points
2021-04-07T15:30:04.407+00:00 thank you Castorix31, again very much. It is worked