Hi Guys, Is it possible to have a list/collection of objects that inherit from a single base object without losing Intelli-sense? Here is an example of what I mean...
Public Class baseblob
Private \_position As PointF
Property position
Get
Return \_position
End Get
Set(value)
\_position = value
End Set
End Property
Sub New()
position = PointF.Empty
End Sub
End Class
Public Class blob
Inherits baseblob
Sub moveRight(ByVal Distance As Single)
position = New PointF(position.X + Distance, position.y)
End Sub
End Class
Public Class Form1
Dim blob As New blob
Dim blobs As New List(Of baseblob)
Private Sub Button1\_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
blob.moveRight(10)
MsgBox(blob.position.x)
blobs.Add(blob)
MsgBox(blobs(0).position.x)
blobs(0).moveright(10)
MsgBox(blobs(0).position.x)
End Sub
End Class
... but of course in the above example i get
'moveright' is not a member of 'oopTest.baseblob'
:doh: So it wants me to use
Dim blobs As New List(Of Object)
So it will compile and work as intended... I just wanted to know is there something I'm missing here? Why can't I just let it know that it's a base object and to list all the possible methods/properties etc of the base class and also any objects that inherit the base class? Give me the lot! To me it doesn't sound like such a hard thing to ask of the compiler/dev environment... why cant it do it ? :(