I'm a beginner to Visual Studio, I can create Windows From Projects and Console Projects just fine, but I can't compile Empty Projects,
The steps I take are:
Put the following code in the class:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace Circles { class Program { static void Main(string[] args) { MessageBox.Show("Hello World!"); } } }
Then I hit compile, and it gives me this error:
Error 1 Program 'D:\C #\Projects\Circles\Circles\obj\x86\Debug\Circles.exe' does not contain a static 'Main' method suitable for an entry point Circles
The Properties build action is set to compile, but the Startup Object in the Project roperties is not set, is this causing the problem, if so what can I do?
EDIT: Question resolved see CharithJ's answer below. Thanks Guys.
Microsoft Visual C++ is a integrated development environment (IDE) used to create Windows applications in the C, C++, and C++/CLI programming languages.
A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.
We don't recommend that you delete any Visual C++ redistributable, because doing so could make multiple applications on your computer stop working. Given how little space they take up and how broadly they are used, it doesn't seem worth the hassle to mess with your current ecosystem of standard library files.
C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.
You need to add the public
access modifier to the class and the main method, and make main begin with an upper-case m:
public class Program
{
public static void Main(string[] args)
{
MessageBox.Show("Hello World!");
}
}
Edit: As per comments, neither public access modifier is actually required.
main
method name should be Main
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Circles
{
public class Program
{
public static void Main(string[] args)
{
MessageBox.Show("Hello World!");
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With