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

前端 未结 10 1162
梦毁少年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:16

    For most purposes it will make no difference. Microsoft advocates making Main private.

    The only real value in doing this (as far as I am aware) is that it will prevent the Main method from being invoked directly by another application's codebase.

    A good discussion of it is available here

提交回复
热议问题