views:

147

answers:

6

I am in the process of learning C#. I downloaded and installed Visual Studio 2010 Express with C#. The problem is it has all these templates that are a little overwhelming at the moment: ASP.NET website, Library, WCF, etc.

I just want to code something very simple that takes input from the Console and outputs to it. I am making do with WCF but that's really inconvenient. It is faster for me to load up ideone.com, type my code there and compile than doing it from own my machine.

Is it even possible to create simple programs like that in C# using VS2010 Express?


Thanks everyone who answered. I installed Visual C# and now I can create console applications. But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?

+4  A: 

You can create simple apps by choosing Windows Application (if you want a GUI) or Console Application (if you just want to take input from console as you describe in the question) as project types.

Anna Lear
Those options don't seem to be available to me. I'll reinstall the IDE.
pessimopoppotamus
Apparently I have the "Web Developer" version installed
pessimopoppotamus
Yes, you have the Web developer. You can install C# Express next to it.
Henk Holterman
A: 

Visual Studio can be extremely overwhelming. What you should remember is that it's a tool for professionals, ultimately. However, if you want to make a Console app, it's quite simple.

  1. Open Visual Studio
  2. File
  3. New
  4. Project
  5. Other Languages
  6. Visual C#
  7. Windows
  8. Console Application

Done.

DeadMG
I don't have that option. I am installing Visual C# now, which is going to take 727 MB (!) extra space.
pessimopoppotamus
A: 

Yes, Visual Studio Express is a very good free tool for creating applications. Of course it doesn't have all of the features of Visual Studio, but I use it at home for several reasons.

Jerod Houghtelling
+3  A: 

Regarding the question of the console window immediately closing, the quick-and-simple fix for this is to have

Console.ReadLine();

at the end of program execution -- it'll do all it needs to do, then wait for (any) keyboard input before closing the window.

Peter Leppert
Alternatively Console.ReadKey(); can also be used except it waits for a single key press as opposed to an entire line worth
Xander
+1  A: 

"But now the command window closes immediately after it's done doing whatever it's doing. Can I have it output to the IDE like I would with Java on Eclipse or Netbeans?"

Try running without debug mode (Ctrl+F5 or Shift+F5 or some other binding depending on your keyboard setting). The program will wait for you to press a key to exit.

If you want to output it to the IDE, you could use System.Diagnostics.Trace.Write, which writes to the trace output in the bottom on the IDE. I do not believe there is a built in stdout view in Visual Studio... but it seems like a great idea for a feature...

Are you there, Microsoft?

Kizaru
A common approach is a Console.ReadLn() or .ReadKey() as last statement.
Henk Holterman
A: 

What you want is the "Console Project" template

George Mauer
Thanks, but it just wasn't there. Otherwise I would have noticed it. I wasn't aware that the Web Developer edition didn't include this template.
pessimopoppotamus
You have the web-express? Get the visual studio C# express instead. So I guess the answer to your question is no, there is no way to make a simple console app with the visual studio express web edition.
George Mauer