vb to c#问题?
vb代码如下:
Public Overloads Sub Show(ByVal Msg As String)
Label1.Text=Msg
Me.Show()
End Sub
我改成c#
public overrides void Show(string Msg)
{
Label1.Text=Msg;
this.Show();
}
编译的时候出错。找不到适合的方法重写。vb的代码可以通过编译的!
这是为什么?
问题点数:20、回复次数:4Top
1 楼offer(煮熟的米饭)回复于 2003-11-03 23:38:02 得分 10
在你所继承的父类里声明一个virtual的方法就可以了。如:
public class hello
{
public virtual void show(string msg)
{
.....
}
}
public class hello2:hello
{
public override void show(string msg)
{
.......
base.show();
}Top
2 楼orcale()回复于 2003-11-04 08:06:36 得分 0
樓上的,Show方法是form自帶的Top
3 楼ruihuahan(飞不起来的笨鸟)回复于 2003-11-04 08:33:01 得分 5
this.Show();->base.Show()Top
4 楼turbomagic(蓝天鹅)回复于 2003-11-05 09:49:19 得分 5
楼上的还带了四个*,确忽视了最小的细节,呵呵.
this.Show();改成this.Show("");绝对pass.Top




