C# - 方法必须有一个返回类型 [英] C# - Method must have a return type
本文介绍了C# - 方法必须有一个返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题,要求在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() {}
}
这篇关于C# - 方法必须有一个返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文