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

前端 未结 6 721
野的像风
野的像风 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:45

    For historical reasons. C++ evolved from C, which had a global main() function. C# is much younger and was designed from scratch. One of the design features of C# is the absence of global functions, so the main function has to belong to a class.

提交回复
热议问题