Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C# main function [Resolved]

Discussion in 'Scripting' started by ItsaMeTuni, Jan 30, 2015.

  1. ItsaMeTuni

    ItsaMeTuni

    Joined:
    Jan 19, 2015
    Posts:
    44
    Well, i dont know if here is a good place to make this question, but i havent found any answers that would explain it in a way that i could understand.
    So heres the question: in C# what does "public static void Main ()" means? I know that public determines that this function can be accessed from outside the class, and that static means that it can be called without an instance running (from what i understood), and that Main is the function that starts the program. But void, what is it?

    I know that with unity we dont use it, but i dont have any other forum to post, this is the only one that i am subscribed.

    Sorry for my bad english, and thank you for the attention.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    In a regular C# app main is the function your app enters in. Your app will run from the beginning of main to the end, and do nothing else.

    Essentially you have one magic function that gets called, instead of Unity's thousands.
     
  3. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    In most languages with C-like syntax (like C#, Java, etc), void is the return type, or what the method returns. It basically means, "does not return anything", i.e. a method of type void will not have a return statement.

    If you're looking for general programming help, I'd also recommend StackOverflow. I've found it to be pretty helpful in the past.
     
    RealSoftGames likes this.
  4. ItsaMeTuni

    ItsaMeTuni

    Joined:
    Jan 19, 2015
    Posts:
    44
    Thank you!
    You explained just as i wanted, with a short explanation and without that advanced "technical" terms.

    And i will look at the StackOverflow.

    Again, Thank you!
     
    RealSoftGames likes this.