<P>定義一個基類Student,它有個虛方法如下:</P> <P>public virtual string getFriends()<BR> {<BR> return "我們是朋友";</P> <P> }</P> <P>定義一個子類GoodStudent類,它的方法重寫了基類中的getFriends()方法,如下:</P> <P>public override string getFriends(string name)<BR> {<BR> return "我和" + name + "是戀人";<BR> }</P> <P>調用如下:</P> <P>GoodStudent xiaoMin = new GoodStudent();<BR> Label1.Text = xiaoMin.getFriends("haha");</P> <P>運行出現以下錯誤:<STRONG>編譯器錯誤信息: </STRONG><FONT face=Arial>CS0115: “GoodStudent.getFriends(string)”: 沒有找到適合的方法來重寫</FONT></P> <P><FONT face=Arial></FONT> </P> <P> </P>
- 2 回答
- 0 關注
- 586 瀏覽
添加回答
舉報
0/150
提交
取消