M
Mykl
I'm trying to derive a class from ArrayList. When I try to use the
Overrides keyword on the Item property, the IDE underlines Item in my
Function definition and says "Item conflicts with a property by the same
name declared in ArrayList"... what gives? Am I out to lunch? I should
add that I'm still a little new to OO and inheritance, polymorphism, etc,
and would really like to understand this...
Here's my code:
Public Class NickNamesCollection
Inherits ArrayList
Public Overloads Function Add(ByVal subjectName As String) As String
MyBase.Add(subjectName)
End Function
' This is where the error occurs
Public Overrides Function Item(ByVal idx As Integer) As String
If idx < MyBase.Count Then
Return CType(MyBase.Item(idx), String)
Else
Throw New Exception("The subject has only " &
MyBase.Count.ToString & " nick-names")
End If
End Function
Public Function GetString() As String
Dim i As Integer
Dim str As String
For i = 0 To MyBase.Count - 1
str = str & MyBase.Item(i).ToString & vbCrLf
Next
Return str
End Function
End Class
Thanks,
Michael
Overrides keyword on the Item property, the IDE underlines Item in my
Function definition and says "Item conflicts with a property by the same
name declared in ArrayList"... what gives? Am I out to lunch? I should
add that I'm still a little new to OO and inheritance, polymorphism, etc,
and would really like to understand this...
Here's my code:
Public Class NickNamesCollection
Inherits ArrayList
Public Overloads Function Add(ByVal subjectName As String) As String
MyBase.Add(subjectName)
End Function
' This is where the error occurs
Public Overrides Function Item(ByVal idx As Integer) As String
If idx < MyBase.Count Then
Return CType(MyBase.Item(idx), String)
Else
Throw New Exception("The subject has only " &
MyBase.Count.ToString & " nick-names")
End If
End Function
Public Function GetString() As String
Dim i As Integer
Dim str As String
For i = 0 To MyBase.Count - 1
str = str & MyBase.Item(i).ToString & vbCrLf
Next
Return str
End Function
End Class
Thanks,
Michael