Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Aug 2nd, 2004 07:45 AM Post subject: Implementing IList in .NET |
|
|
I'm just learning VB.Net and it took me 1/2 a day to figure out how to create a class that implements IList. I'm posting the code here to help anyone else that might need it.
[vb:1:5996f39e57]Dim NewIListClass as New IListClass
Class IListClass
Implements IList
' Shell of IList interface
Private _Item As Object
Private _Count As Integer
Private _IsFixedSize As Boolean
Private _IsSynchronized As Boolean
Private _SyncRoot As Object
Private _IsReadOnly As Boolean
Default Property Item(ByVal index As Integer) As Object _
Implements IList.Item
Get
Item = _Item
End Get
Set(ByVal Value As Object)
_Item = Value
End Set
End Property
Public ReadOnly Property Count() As Integer _
Implements IList.Count
Get
Count = _Count
End Get
End Property
Public ReadOnly Property IsFixedSize() As Boolean _
Implements IList.IsFixedSize
Get
IsFixedSize = _IsFixedSize
End Get
End Property
Public ReadOnly Property IsReadOnly() As Boolean _
Implements IList.IsReadOnly
Get
IsReadOnly = _IsReadOnly
End Get
End Property
Public ReadOnly Property IsSynchronized() As Boolean _
Implements IList.IsSynchronized
Get
IsSynchronized = _IsSynchronized
End Get
End Property
Public ReadOnly Property SyncRoot() As Object _
Implements IList.SyncRoot
Get
SyncRoot = _SyncRoot
End Get
End Property
Private Function Add(ByVal o As Object) As Integer _
Implements IList.Add
Return Me.Add(CType(o, Object))
End Function
Public Function Contains(ByVal value As Object) As Boolean _
Implements IList.Contains
End Function
Public Function GetEnumerator() As IEnumerator _
Implements IList.GetEnumerator
End Function
Public Function IndexOf(ByVal value As Object) As Integer _
Implements IList.IndexOf
End Function
Public Sub Clear() _
Implements IList.Clear
End Sub
Public Sub CopyTo(ByVal array As Array, ByVal index As Integer) _
Implements IList.CopyTo
End Sub
Public Sub Insert(ByVal index As Integer, ByVal value As Object) _
Implements IList.Insert
End Sub
Public Sub Remove(ByVal value As Object) _
Implements IList.Remove
End Sub
Public Sub RemoveAt(ByVal index As Integer) _
Implements IList.RemoveAt
End Sub
End Class[/vb:1:5996f39e57] _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|