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

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

    There is difference, because first one is public and second one is private, so when you'd try to use the first one from outside the class it would work just fine, but wouldn't work with the second one.

    However, there is no difference if you're trying to make one of these an entry point in you application. Entry point method can be either public or private, it doesn't matter.

提交回复
热议问题