小编jme*_*hus的帖子

从Main()返回字符串变量

我想从我的Main()方法返回一个字符串变量.我已经返回了int变量.但是我不确定退出程序时是否可以从Main()返回一个字符串变量?

有任何想法吗?

这是我的int代码:

    public class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static int Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());

        int error = 1;

        return error;

    }

}
Run Code Online (Sandbox Code Playgroud)

如果我将int更改为string,则会出现此错误:Program不包含适用于入口点的静态"Main"方法.显然这是不允许的.什么是正确的方法?

c#

9
推荐指数
1
解决办法
9147
查看次数

标签 统计

c# ×1