Search code examples
c#program-entry-pointvoid

C#:: What is the difference between int main(){...} void main(){...} int main(void){...} void main(void){...}


I am new to programming
I am coding in C# and its kind of confusing.

What is the difference between these:
Method signatures

Thank you very much in advance!


Solution

  • 1- function uses to return an integer number

    int main()
    {
      return 1;
    }
    

    so if you call this function like this:

    int x = main();
    

    result of x will be "1"

    2- void function does n't return any value

    void main()
    {
      Console.WriteLine("Hello World");
    }
    

    so you can call this function like this:

    void main();
    

    this just execute "void main" function and would not return anything