为什么Main方法私有? [英] Why is Main method private?

查看:194
本文介绍了为什么Main方法私有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的控制台项目模板创建了一个主要的方法是这样的:

New console project template creates a Main method like this:

class Program
{
    static void Main(string[] args)
    {
    }
}

为什么,无论是的方法,也不是计划类必须公开?

Why is it that neither the Main method nor the Program class need to be public?

推荐答案

程序的入口点是标有 .entrypoint IL指令。这不要紧,如果该方法或类是公共与否,最重要的事情是这样的指令。

The entry point of a program is marked with the .entrypoint IL directive. It does not matter if the method or the class is public or not, all that matters is this directive.

这篇关于为什么Main方法私有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆