关于c#/vb.net 的问题,如果list类型作为属性编译不通过的错误?

代码如下(vb.net)
//Piece是我自定义的一个很简单的类。
//这代码是在另外一个类里面
Private m_Pieces As List(Of Piece)
Public Property Pieces() As List(Of Piece)
Get
Return m_Pieces
End Get
Set(ByVal value As List(Of Piece))
m_Pieces = value
End Set
End Property
编译错误:
Public Property Pieces As System.Collections.Generic.List(Of Piece)”和“Public Property Pieces As System.Collections.Generic.List(Of Procedure)”的差异仅在于返回类型,因此它们无法重载对方。
英文版错误:
You have attempted to overload a method with another method that differs from the first only in its return type. In overloading, you must differentiate any two versions of a method by their argument lists; you cannot use anything other than argument lists to differentiate the methods.

开心每一天1111
浏览 263回答 1
1回答

侃侃无极

这个另外的类有一个基类吧,你重载了Pieces属性但是返回了与基类不同的类型,所以出错了
打开App,查看更多内容
随时随地看视频慕课网APP