473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Implementing IList

Don
I have a class which contains a collection of objects that I want to be able
to bind to things like Combobox controls. As I understand it, I would need
to implement the IList interface to be able to do this.

I am having trouble implementing the GetEnumerator() method. From what I
could gather on the few articles I could find online, it would appear that
this method has to return an instance of a class that implements
IEnumerator. Is this correct? If so, is it proper to do the following
(cutting out lots of implementation code):

Public Class MyList
Implements IList

...

Public Function GetEnumerator() As System.Collections.IEnumerator _
Implements System.Collections.IEnumerable.GetEnumerator

Return New MyListEnum(Me)

End Function

...

End Class

Public Class MyListEnum
Implements Enumerable

Private _List as MyList

Public Sub New(ByVal theList as MyList)
_List = theList
End Sub

<...implement methods for enumerating the _List object here...>

End Class

? Or am I missing the point entirely?
- Don
Nov 21 '05 #1
1 2287
Don
This knowledge base article gave me the info I needed:

http://support.microsoft.com/kb/306961/EN-US/

- Don

"Don" <un*****@oblivion.com> wrote in message
news:aCrid.115448$Pl.36106@pd7tw1no...
I have a class which contains a collection of objects that I want to be able to bind to things like Combobox controls. As I understand it, I would need to implement the IList interface to be able to do this.

I am having trouble implementing the GetEnumerator() method. From what I
could gather on the few articles I could find online, it would appear that
this method has to return an instance of a class that implements
IEnumerator. Is this correct? If so, is it proper to do the following
(cutting out lots of implementation code):

Public Class MyList
Implements IList

...

Public Function GetEnumerator() As System.Collections.IEnumerator _
Implements System.Collections.IEnumerable.GetEnumerator

Return New MyListEnum(Me)

End Function

...

End Class

Public Class MyListEnum
Implements Enumerable

Private _List as MyList

Public Sub New(ByVal theList as MyList)
_List = theList
End Sub

<...implement methods for enumerating the _List object here...>

End Class

? Or am I missing the point entirely?
- Don

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
0
by: Brian Takita | last post by:
Hello, I am trying to Implement a DataSource property for a custom control using a ListView. This DataSource should be like all other DataSource properties for data bound controls in .NET. The...
3
by: Chris | last post by:
Hi, the specs for System.Array are : public abstract class Array : ICloneable, IList, ICollection, IEnumerable but I can't use any of the functions presented by IList in my code ...
2
by: Michael Groeger | last post by:
Hi, is it possible to determine if the PropertyType of a property support IList? We are inspecting all properties of a Type and we need to care about the properties which have a type which...
1
by: Marek | last post by:
Hi I have a user control that has a property which is a class implementing IList: public partial class MultiPanelControl : UserControl { protected MultiPanelList _panels = new MultiPanelList();...
2
by: Lucian Wischik | last post by:
Does ReadOnlyCollection<T> really implement IList<T>, like it claims to do? ... When I right-click on ReadOnlyCollection and look at its definition, it says this: public class...
1
by: jjsavage | last post by:
Hi all, I've got a MyList class that implements the IList<string> interface. I can do all the IList-specific methods, but when I try to do the ICollection ones, it says "Error: 'Form1.MyList'...
6
by: nicolas.rolland | last post by:
Would anyone know the reson why IList<Tdoes not implements IList ?? This results in strange behaviours, like typeof(IList).IsAssignableFrom(typeof(List<string>)) --true...
0
by: Frank Osterberg | last post by:
Hi, if I create a class that implements the List interface then instances of it will be serialized as "ArrayOfType" and not as "ClassName", which also means that any public members will not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.