How do I input a script - a C# prog such as 'hello world' - into the MS IDE? Here's the script:
// Namespace Declaration
using System;
// Program start class
class WelcomeCSS
{
// Main begins program execution.
static void Main()
{
// Write to console
Console.WriteLine("Welcome to the C# Station Tutorial!");
}
}
I have just begun my 'learn C#' journey. I have found what seems an excellent tutor - "C# Station". That's where that script comes from.
And I've found a problem. I can't compile from the command prompt. My machine is screwed up, probably, with installations of Visual Studio from 2005, 2008 and 2009, been there for yonks. I ran the batch file but it didn't correctly set the environment vars.
That script was meant to be run from the command line.
I downloaded and installed Mondevelop but that didn't help.
Can anyone steer me right?
regards,
ab :)
Loading
Sam HobbsPosted Mar 3, 2010, 2:46 AM
Try using VS; execute it. When it has started, click on "File | New | Project". In the "New Project" dialog, in the "Project Types" at the top left, expand the Visual C# node. Select Windows. In the list of Templates at the right of Project Types, select Console Application. Give a name near the bottom. Ensure that the "Create directory for solution" checkbox is not checked. Then press OK.
That will create a project that will already have most of the code you showed. Don't change anything; just select "Build | Build Solution". That will compile and link the program. To execute, use "Debug | Start without debugging" (Ctrl-F5). Note that if you use "Debug | Start Debugging" (F5) then the program will execute but then the window will close immediately, just the same as console programs normally work when they are executed from non-console applications such as Windows Explorer. If you use "Debug | Start without debugging" then VS will pause after the program finishes and give you have a chance to see the results.
So then modify the program. Then build it again and execute again. Do that until you get too hungry or sleepy to continue; I think you wil have fun.