© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
8 replies
tommy

Why do we enclose the `Main` function inside of a class in C#?

After learning C++, I think it makes sense to include the
main
main
function outside of a class. Why do we not do it in C#?
Like what disadvantage I would have by not including the
main
main
function in a class in C++? Would it be accessible to everyone? Does including the
Main
Main
method in a class in C# make it "safer" than it being present at a global scope? What is the reason behind this?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

why is there "string[] args" inside the main function parentheses?
C#CC# / help
2y ago
✅ How to do the C# equivalent of passing an std::function into a class
C#CC# / help
3y ago
Can't access a function inside a class library
C#CC# / help
11mo ago
No Main and class confusion in newer C# versions
C#CC# / help
2y ago