Jump to content

c# compile


XSV_SOLJA

Recommended Posts

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.

Link to comment
Share on other sites

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 :P

 

Another way/posibility is:

 

http://stackoverflow...-an-entry-point

Check the properties of App.xaml. Is the Build Action still ApplicationDefinition?
Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

  • 4 months later...

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 by uncasid
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.