Hi all,
In my current situation I have two classes;
1. ClsItem - one is the class with properties (like name and value)
2. ClsCol - one is the class having a private collection object and storing the items with the type of class 1.
What I want to do is implement a 'items' property that is used in the for each loops. Now, what I thought was this in the ClsCol;
VB Code:
Private m_Data As Collection Public ReadOnly Property Data() As IEnumerable(Of ClsItem) Get Return m_Data End Get End Property
Using the IEnumerable(Of ClsItem) I though I would be able to do a for each like this;
VB Code:
Dim col As New ClsCol 'Add some items... For Each item As ClsItem In col.Data 'Do something with 'item' Next
However, the compiler says that I can not cast the m_Data as ClsItem in the Items property...
Can anyone help me out here?
Thanks.
P.s. Using VS 2005




Reply With Quote