由网友(眉目成书)分享简介:我有问题,要求在C#中的方法,我不断收到的消息方法(计算)必须有一个返回类型。使用System.Diagnostics程序;命名空间WindowsFormsApplication1{公共部分类Form1中:形态{公共Form1中(){的InitializeComponent();}}公共类您好:表{公共字符串测试{获...
我有问题,要求在C#中的方法,我不断收到的消息方法(计算)必须有一个返回类型。
使用System.Diagnostics程序;
命名空间WindowsFormsApplication1
{
公共部分类Form1中:形态
{
公共Form1中()
{
的InitializeComponent();
}
}
公共类您好:表
{
公共字符串测试{获得;组; }
计算();
}
公共类Hello2:表
{
公共无效计算()
{
的Process.Start(TEST.EXE);
}
}
解决方案
计算();
是在您好无效的方法签名
类。它缺少的返回类型,它也需要一个身体。
在最低限度的签名应该是这样的:
公共类您好:表
{
公共字符串测试{获得;组; }
无效计算(){}
}
I am having problems calling a method in C#, I keep getting the message "Method (calculate) must have a return type".
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
public class Hello : Form
{
public string test { get; set; }
calculate();
}
public class Hello2 : Form
{
public void calculate()
{
Process.Start("test.exe");
}
}
解决方案
calculate();
is an invalid method signature in your Hello
class. It is missing the return type and it also needs a body.
At a minimum the signature should look like:
public class Hello : Form
{
public string test { get; set; }
void calculate() {}
}
相关推荐
最新文章