why main method in c# is always placed inside the class but not in c++

前端 未结 6 738
野的像风
野的像风 2021-01-01 23:49

Why we put main() method always inside the class in C# while in c++ it always placed outside of the class.

6条回答
  •  渐次进展
    2021-01-02 00:38

    Because in .NET you can place methods only inside types. You cannot have them floating around in the empty space. C++ has its legacy from C which is not an OOP language so you could define functions anywhere.

提交回复
热议问题