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

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)