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# C# Objects Object-Oriented Programming Object Initialization

Al Yuri Félix
Al Yuri Félix
3,718 Points

static vs public void main()

I'm using VS2017 and when I wanted to run the program I had an error. I needed to change the public void main() for static void main(). What is the major difference between those two?

1 Answer

Steven Parker
Steven Parker
231,248 Points

The "Main" method should be both "public" and "static" (and "void" because it returns nothing).

The "public" is the accessibility and "static" means that it can be referenced directly in the class without creating an instance. You will likely see more about these terms later in the course.