一个CS文件中的多主 [英] Multi Main in one cs file

查看:72
本文介绍了一个CS文件中的多主的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在.cs文件中使用多个main,以及如何编译和运行它?

Is it possible using more than one main in .cs file and how to compile and run it?

推荐答案

您实际上应该只有一个main方法.与使用"mutlimain"方法为您提供的编译器定义,甚至命令行参数相比,您可以实现基本相同的设计.在逻辑上没有理由在应用程序中具有两种主要方法.除此之外,这还成为维护问题.

简而言之-这是不好的做法,而且只是一个简单的坏主意.我的建议-找到另一种方法.
You should really only have one main method. You can achieve essentially the same thign as what using the "mutlimain" approach gives you with compiler definitions, or even commandline parameters. There is no logical reason to have two main methods in an application. Beyond al that, it becomes a maintenance issue.

In short - it''s bad practice, and just a plain bad idea. My advice - find another way.


是的,有可能.

请参阅 [
Yes it is possible.

See THIS[^] having exact what you need.


通过下面的链接

此处 [此处 [ ^ ]
Go through the below link

Here[^]
Here[^]


这篇关于一个CS文件中的多主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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