What is the difference between
public static void Main()
and
private static void Main()
in a C# console application? Specifically as it pertains to the Main()
method (I understand the differences between public
and private
).
To act as the start point in your application, the Main
method is not required to be public
.
If you did decide to make it public
, it would be possible for it to be called from other classes or assemblies. Typically you will not need to do this, so you can keep it private
.
One possible use case for making it public
would be to allow automated tests to invoke it.