Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

What is a ,,static void main()'' Method

Hello Guys, What is a ,,static void main()'' Method? Easy explantion, please

1 Answer

When you declare a static void() method in your class you can call it without having to initialize an object of the class:

System.Console.WriteLine("Hello World");

To print "Hello World" with the WriteLine() method to the console you don't have to initialize an object of System.Console .

Void just means that your method won't return anything.

Main is always the starting point of your program so it has to be static. Otherwise you have to initialize an object before the program starts.