为什么在大多数C#程序的主要方法入口点静态?

编程入门 行业动态 更新时间:2024-10-17 13:28:51
本文介绍了为什么在大多数C#程序的主要方法入口点静态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为什么在大多数C#程序静态的?

Why is the main method entry point in most C# programs static?

推荐答案

的主要方法入口点为了调用你需要一个实例方法一个对象的一个​​实例。这意味着为了启动程序的CLR将需要以调用方法来创建发言权程序的实例主。因此,程序的构造将主这违背了完全具有主的目的之前运行。

In order to call an instance method you need an instance of an object. This means in order to start your program the CLR would need to create an instance of say Program in order to call the method Main. Hence the constructor of Program would run before Main which defeats the purpose of having a main altogether.

更多推荐

为什么在大多数C#程序的主要方法入口点静态?

本文发布于:2023-11-10 02:47:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574132.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   入口   程序   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!