我的 "x.cs" 出错
Error in my "x.cs"
我正在编写这个(非常)简单的 C# 代码,用 Mono 发送到我的 Raspberry Pi。这是新手,我收到错误
("} expected") & ("Type or namespace definition, or end-of-file
expected")
你们能帮我编译一下吗? (顺便说一句,运行 mcs on mono in linux 告诉我将 static public void Main () {}
添加到 .cs 文件中。
using System;
public class helloWorld
{
public helloWorld()
{
static public void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
}
您正在构造方法中声明静态 Main
函数。
将此更改为:
using System;
public class helloWorld
{
public helloWorld()
{
// ...
}
static public void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
using System;
namespace MyFirstProgram
{
public class helloWorld
{
public static void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
}
您在方法中还有一个方法是不允许的。命名空间在技术上不是必需的,但在创建较大的项目时开始使用它们是一个好习惯。
我正在编写这个(非常)简单的 C# 代码,用 Mono 发送到我的 Raspberry Pi。这是新手,我收到错误
("} expected") & ("Type or namespace definition, or end-of-file expected")
你们能帮我编译一下吗? (顺便说一句,运行 mcs on mono in linux 告诉我将 static public void Main () {}
添加到 .cs 文件中。
using System;
public class helloWorld
{
public helloWorld()
{
static public void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
}
您正在构造方法中声明静态 Main
函数。
将此更改为:
using System;
public class helloWorld
{
public helloWorld()
{
// ...
}
static public void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
using System;
namespace MyFirstProgram
{
public class helloWorld
{
public static void Main ()
{
Console.WriteLine("Hello World! You´re welcome m8!");
}
}
}
您在方法中还有一个方法是不允许的。命名空间在技术上不是必需的,但在创建较大的项目时开始使用它们是一个好习惯。