question

StefanosTsitmidelis-8001 avatar image
0 Votes"
StefanosTsitmidelis-8001 asked StefanosTsitmidelis-8001 answered

C# problem with System.Windows.Forms console application

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

dotnet-csharp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Do you really need a message box? In console applications you can write:

 Console.WriteLine("Random Numbers from 1 to 6:");
 Console.WriteLine(output);

0 Votes 0 ·

yes i need it for educational purposes.My problem is to add System.Windows.Form in the project.

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered StefanosTsitmidelis-8001 commented

Right-Click on project,
[Add]
[Reference...]
System.Windows.Forms

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

i Thank you for your answer
but it didn't work or i didnt understand.
Yes my problem is to add System.Windows.Form in the project.
85280-img1.jpg


I cant find how to add it.

0 Votes 0 ·
img1.jpg (30.8 KiB)
Castorix31 avatar image Castorix31 StefanosTsitmidelis-8001 ·

Apparently, you created a .NET Core project instead of a .NET Framework Project

Try with a .NET Framework Project :

85354-console-netframework.jpg


0 Votes 0 ·

Thank you Very Very much. It is the solution

0 Votes 0 ·
StefanosTsitmidelis-8001 avatar image
0 Votes"
StefanosTsitmidelis-8001 answered

thank you Castorix31, again very much. It is worked

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.