Question:
What are the steps in Visual Studio.net to run this code?
the man
2010-07-15 17:43:00 UTC
I am currently trying to run this code in visual studios.net. How or where would I go to put this code in visual studio.net. Is it a windows application if so what are the steps I would take to run this instead of the form which is there by default. Attached is the code.

using System;
using System.Windows.Forms;

class SumArray
{
static void Main( string[] args)
{
int[] n = {19, 3, 15, 7, 11, 9, 13, 5, 17, 1};

string output = "";

output += "Element\tvalue\tHistogram\n";

for ( int i = 0; i < n.Length; i++)
{
output += "\n" + i + "\t" + n[i] + "\t";

for ( int j = 1; j <= n[i]; j++ )
output += "*";
}
MessageBox.Show( output, "Histogram Printing Program",
MessageBoxButtons.OK, MessageBoxIcon.Information );
Four answers:
anne p
2010-07-15 22:34:22 UTC
Hi,



You combined the console application and windows form code. You can try the code with both ways with a little modification but i guess its more of a windows form.



"static void Main( string[] args)" is used for console app or the dos-like output interface.

"using System.Windows.Forms" and "messagebox" is used for windows form and are not available for console app.



to make it run via windows form (im assuming you already created a new windows form project in c#):

(1) go to the code-behind of the form by double clicking the form itself or the view code option from solution explorer. (2) you'll see the Form1_Load statement. Copy and paste the code from int[] n = ... until the messagebox inside the { } of Form1_Load. (3) Press f5 to view the results.
?
2010-07-15 17:46:40 UTC
You can buy Visual Studio .NET in your software store or you could download trial version. If you want to run this code, you have to save it in VB format, debug and then click the run button which I suppose is F5 or CTRL+F10, I am not sure since I don't use this application for 2 years..
2016-11-07 13:45:05 UTC
it somewhat is authentic that in case you create an empty C++ console project and manually rename your cpp report to furnish it .c extension, seen Studio *will* execute the Microsoft C compiler, even though it somewhat is a doubly-out of date 1989 C compiler. Microsoft abandoned C an prolonged time in the past. in case you desire to stay with this IDE and convey at the same time C, replace the underlying compiler. Intel C/C++ is a robust decision.
nsgnc
2010-07-15 17:46:58 UTC
Did you install visual studio?

create a project and double click the form.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...