c#中的例子不知道怎么调通

来源:百度知道 编辑:UC知道 时间:2024/05/25 05:21:44
using System;

class Test
{
public static void Main()
{
string text = GetButtomCaption;
switch (text)
{
case "OK": ShowMessage("save the change and exit"); break;
case "Retry": ShowMessage("return and retry"); break;
case "Abort": ShowMessage("Abort the change and exit"); break;
case "HELP": ShowMessage("Get help from system"); break;
}
}
}
GetButtomCaption以及 ShowMessage等于说都是作者定义的,而作者没有把怎么定义的写出来是吧
那两处错误是复制上来的时候弄错的。
例子里就写了
string text = GetButtomCaption();
switch (text)
{
case "OK": ShowMessage("save the change and exit"); break;
case "Retry": ShowMessage("return and retry"); break;
case "Abort": ShowMessage("Abort the change and exit"); break;
ca

你程序中没有写GetButtomCaption()这个方法.
你加一个返回STRING类型的GetButtomCaption()就可以了.或者用别的方法取得你要的值吧.

string text = GetButtomCaption;
这个有问题,你可以做个字符串数组或者利用Label2的text属性的改变来检测switch啊,还有就是case default:break;这句应该加上

GetButtomCaption

是方法还是属性 如果是方法 应该写成GetButtomCaption()

而且 你应该把具体的错误信息贴上来

string text = button1.text;
MessageBox.Show("");