未找到命名空间'rextester'中的类'program'中的入口方法'main' [英] Entry method 'main' in class 'program' in namespace 'rextester' not found
问题描述
您好,我们正在为我们的工作在培训元素中学习一些关于C#的知识,他们给了我们这段代码来说明它的作用以及一切如何运作。我试图在这个名为Rextester的在线编译器中编译它,但由于此错误它无法正常工作。有人可以帮我指导并告诉我应该怎么做吗?我对编程一无所知,所以请原谅我,如果整件事搞砸了
这是代码
Hello, we're learning a little bit about C# in a training element for our job and they gave us this code to figure what it does and how everything works. I tried to compile it in this online compiler called Rextester, but it didn't work because of this error. Can someone help guide me and tell me what I should do? I don't know anything about programming, so please forgive me if this whole thing is messed up
This is the code
using System;
using System.Collections.Generic;
namespace Rextester
{
class Program
{
static void Main(String[] args)
{System.Console.WriteLine(args.Length);
}
static List<string> Loader(){
List<string> load = new List<string>();
for(int j = 0; j < 10; j++){
load.Add(" ");
}
load[4] = "Banana";
load[1] = "pineapple";
load[5] = "pear";
load[7] = "Cat";
load[6] = "Taco";
load[9] = "Wae";
load[0] = "pen";
load[2] = "Apple";
load[8] = "De";
load[3] = "Pen";
List<string> range = Loader();
foreach (var item in range)
Console.WriteLine (item);
return load;
}
}
}
我尝试了什么:
使用不同的命名空间更改单词main
的大小写
更改班级
更改返回类型
What I have tried:
Changing the case of the word main
using a different namespace
changing the class
changing the return type
推荐答案
将您的代码与Rextester页面上的骨架进行比较。在那里Main()
方法被声明为public
。
虽然没有必要使用Microsoft C#编译器公开该方法,但Rextester页面似乎需要它。
Compare your code with the skeleton on the Rextester page. There theMain()
method is declaredpublic
.
While it is not necessary to make the method public with the Microsoft C# compiler, it seems to be required by the Rextester page.
这篇关于未找到命名空间'rextester'中的类'program'中的入口方法'main'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!