Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Knowledge Base

Post new topic   Reply to topic
Implementing IList in .NET
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 2nd, 2004 07:45 AM    Post subject: Implementing IList in .NET Reply with quote

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!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic