| Forum: VB.NET |
Thema:
Re: Schnittstellen implementieren |
Von:
Till Groos (
12.02.2004 09:47) |
Hallo Klaas,
deine Klasse muss das Interface IList implementieren.
Das geht wie folgt:
public class
implements IList
end class
das sieht dann wie folgt aus (sollte vom Visual Studio generiert werden):
======================================
Public Class deineklasse
Implements IList
Public Sub CopyTo(ByVal array As System.Array, ByVal index As Integer) Implements System.Collections.ICollection.CopyTo
End Sub
Public ReadOnly Property Count() As Integer Implements System.Collections.ICollection.Count
Get
End Get
End Property
Public ReadOnly Property IsSynchronized() As Boolean Implements System.Collections.ICollection.IsSynchronized
Get
End Get
End Property
Public ReadOnly Property SyncRoot() As Object Implements System.Collections.ICollection.SyncRoot
Get
End Get
End Property
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
End Function
Public Function Add(ByVal value As Object) As Integer Implements System.Collections.IList.Add
End Function
Public Sub Clear() Implements System.Collections.IList.Clear
End Sub
Public Function Contains(ByVal value As Object) As Boolean Implements System.Collections.IList.Contains
End Function
Public Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
End Function
Public Sub Insert(ByVal index As Integer, ByVal value As Object) Implements System.Collections.IList.Insert
End Sub
Public ReadOnly Property IsFixedSize() As Boolean Implements System.Collections.IList.IsFixedSize
Get
End Get
End Property
Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.IList.IsReadOnly
Get
End Get
End Property
Default Public Property Item(ByVal index As Integer) As Object Implements System.Collections.IList.Item
Get
End Get
Set(ByVal Value As Object)
End Set
End Property
Public Sub Remove(ByVal value As Object) Implements System.Collections.IList.Remove
End Sub
Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.IList.RemoveAt
End Sub
End Class
=============================================
All das muss implementiert sein, damit deine Klasse eine Liste wird.
hth
mfgTill
| Betreff |
Von |
Datum |
|
|
  |
Re: Schnittstellen implementieren
| Hi,<br>danke für den Tipp, doch das hat genau das Problem, welches die ArrayList hat: Die Member Add, Item und so haben dann als Typ Object (also keinen Typ), ich wollte aber den Typ myClass... |
 |
 |
 |
|
|
Klaas
Wedemeyer
|
12.02.2004 17:58 |
|
|
|
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!