XSV_SOLJA Posted November 16, 2011 Posted November 16, 2011 I'm going to be going on a three year course on software development and so I want to try get a head start before I leave, it's majority c# with some web development and XNA. I'm using Microsoft visual c# 2010 express but I cant figure out how to compile the source code. I got this sample code to try create a simple program. // Hello.cs public class Hello { public static void Main() { System.Console.WriteLine("Hello, World!"); } } But i get this error when trying to build it gives an error. "Program 'C:\Users\mix-PC\AppData\Local\Temporary Projects\Project1\obj\x86\Release\Project1.exe' does not contain a static 'Main' method suitable for an entry point. Any help is appreciated. Quote
rolf Posted November 16, 2011 Posted November 16, 2011 http://stackoverflow...-when-it-clearl All I needed to do was change the output type of the project properties to Class library I don't have the C# of visual studio installed, so how you should do it correctly is ---I guess--- Project -> $hello Properties and find the correct output type. And yes, in MSVS that's quite hard to find sometimes Another way/posibility is: http://stackoverflow...-an-entry-point Check the properties of App.xaml. Is the Build Action still ApplicationDefinition? Quote
XSV_SOLJA Posted November 23, 2011 Author Posted November 23, 2011 I got the program to compile but nothing happens when i run the compiled program, there is no text dislayed in the console Quote
rolf Posted November 23, 2011 Posted November 23, 2011 No text is displayed and the console closes immediately, or no text is displayed? In the first one, the text is only printed to the console after it flushes the output. This is, basicly, after a newline. This can be achieved by, instead of using ("Hello World!"), use ("Hello World!\r\n") or ("Hello World!" + Environment.NewLine) or one of the other 324234 options Quote
uncasid Posted April 2, 2012 Posted April 2, 2012 (edited) I am the guy to talk to I have worked with XNA and c# . btw, you are forgetting the big one at the end of the console.writeline... Console.readLine(); This will keep the window up so: using System; // Hello.cs public class Hello { public static void Main() { Console.WriteLine("Hello, World!"); Console.ReadLine(); } } And, you fixed the compile because you set the output to a console application, you also need to specifiy where it enters into the program (via csproj settings) Edited April 2, 2012 by uncasid Quote
Krauersaut Posted April 3, 2012 Posted April 3, 2012 Even if he wasn't banned and able to read this, I assume it would be already fixed, considering that he had more than 4.5 months to do so. Anyway, Ctrl+F5 instead of F5 works just fine, without adding any code. Quote
parrot Posted April 3, 2012 Posted April 3, 2012 I dunno if C# is different, but in MS VS for C++ I have to use cin.get(); cin.ignore(); to hold my window open (assuming there was some input requested, otherwise just the first line works) Quote
uncasid Posted April 4, 2012 Posted April 4, 2012 yeah, not the same in c# Most of the mundane is boxed to allow rapid development.. so none of that windows message pump shiz. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.