What is the difference between public static void Main() and private static void Main() in a C# console application?

前端 未结 10 1167
梦毁少年i
梦毁少年i 2021-02-06 20:32

What is the difference between

public static void Main()

and

private static void Main()

in a C# console appli

10条回答
  •  爱一瞬间的悲伤
    2021-02-06 21:15

    The main is marked as the entry point for execution in the exe itself when it is private so anything from outside cannot access it

    Making it public will make the method accessible from outside

    Read for more clarification http://social.msdn.microsoft.com/Forums/vstudio/en-US/9184c55b-4629-4fbf-ad77-2e96eadc4d62/why-is-main-in-c-not-a-public-static-?forum=csharpgeneral

提交回复
热议问题