简体   繁体   English

程序不包含适用于入口点 C# 的静态“Main”方法 test_test

[英]Program does not contain a static 'Main' method test_test suitable for an entry point, C#

CS 5001: Program does not contain a static 'Main' method test_test suitable for an entry point. CS 5001:程序不包含适用于入口点的静态“Main”方法 test_test。

The above error is given then I try to run the program along with an error attracted to the txt file call in the main stating:给出了上述错误,然后我尝试运行该程序,同时出现一个错误,该错误被吸引到主文件中的 txt 文件调用:

there is no argument given that corresponds to the required formal parameter 'arr' of 'txt_program.txt(string[][])'没有给出对应于 'txt_program.txt(string[][])' 的所需形式参数 'arr' 的参数

Furthermore the program is an console app with the following code for an item:此外,该程序是一个控制台应用程序,其中包含以下项目代码:

namespace text_test
}
class txt_program
    {
        public void txt()
        {
        string[] string1 = new string[] {"a", "a", "a" };
        string[] string2 = new string[] { "b", "b", "b" };
        string[] string3 = new string[] { "c", "c", "c" };

        string[][] names = new string[][] { string1, string2, string3 };

            using (StreamWriter SW = new StreamWriter(@"txt.txt"))
            {
             for (int i = 0; i < 3; i++)
            {
                for (int a = 0; a < 3; a++)
                {
                    Console.Write(" " + arr[i][a]);
                }
                Console.WriteLine();
                }
            }
        }
    }
}

The above code is called in the main by using the following code:上面的代码在 main 中使用以下代码调用:

namespace text_test
{
class Program
{
    static void Main(string[][] args)
    {
    new txt_program().txt();
    }
}
}

The wished output is a textfile looking like the following:希望的输出是一个文本文件,如下所示:

a a a
b b b
c c c

Some issues....有些问题……

"there is no argument given that corresponds to the required formal parameter 'arr'" You have no variable declared named 'arr', did you mean to use 'names' here? “没有给出与所需形式参数'arr'相对应的参数”您没有声明名为'arr'的变量,您的意思是在这里使用'names'吗?

These这些

string[] string3 = new string[] { "c", "c", "c" };

You probably meant to do你可能打算这样做

char[] string3 = {'c','c','c'};

but even that is not nessisary, just use但即使那也不是必需的,只需使用

string string3 = "ccc";

Strings are just char arrays already so you can do字符串只是字符数组,所以你可以做

string string3 = "abc";
string3[2] == 'c'; (true)

for this为了这

string[][] args

You probably should have你可能应该有

string[] args

but you never access args here so its not necessary for the code you provided.但是您永远不会在此处访问 args,因此您提供的代码不需要它。

For your startup issues right click the project and in the Application tab of visual studio under startup object you should have 'text_test.Program' selected in the drop down.对于您的启动问题,右键单击该项目,然后在启动对象下的 Visual Studio 的“应用程序”选项卡中,您应该在下拉列表中选择“text_test.Program”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual C#程序“ xyz”不包含适用于入口点的静态“ Main”方法 - Visual C# Program 'xyz' does not contain a static 'Main' method suitable for an entry point CS5001 C# 程序不包含适用于入口点的 static 'Main' 方法 - CS5001 C# Program does not contain a static 'Main' method suitable for an entry point C#程序不包含适用于入口点的静态“ Main”方法 - C# Program does not contain a static 'Main' method suitable for an entry point 程序不包含适用于入口点的静态“Main”方法 - Program does not contain a static ‘Main’ method suitable for an entry point 程序*不包含适用于带有代码的入口点*的静态“主”方法 - Program * does not contain a static 'Main' method suitable for an entry point* with code 程序不包含适合入口点的 static 'main' 方法 - Program does not contain a static 'main' method suitable for entry point 程序不包含适用于入口点的静态“主”方法 - program doesn't contain a static 'main' method suitable for an entry point 由于错误代码,程序将无法运行 * 程序不包含适用于入口点的 static 'Main' 方法 - Program will not run because of error code * Program does not contain a static 'Main' method suitable for an entry point 不包含适用于入口点的静态“ Main”方法; - Does not contain a static 'Main' method suitable for an entry point; 故障排除:不包含适用于入口点的静态“主要”方法 - Troubleshooting: does not contain a static 'main' method suitable for an entry point
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM