Search code examples
c#javarunasmain-method

What is the equivalent Main method for Java in c#


in Java, you can write:

public static void Main(String[] args) { }

and than "right click" => "run as" => "Java application" and it will run the current Main Method.

Any chance to have that in Visual Web Developer?

Thanks


Solution

  • Visual Web Developer is presumably for web applications. Web applications don't run in that sort of way - they respond to web requests.

    The equivalent of a main method (note case) in Java is a Main method in C#, in one of the following forms:

    static void Main(string[] args)
    static void Main()
    static int Main(string[] args)
    static int Main()
    

    The method can have any accessibility, can return int or void, and either be parameterless or take an array of strings.

    That will work fine when creating a console or Windows application - but not a web application. If you want to write desktop applications, use Visual C# Express or something similar.