|
-
Oct 19th, 2007, 04:16 AM
#1
Thread Starter
Fanatic Member
[02/03] Enumerating a subset of a strongly typed collection
Hi
I have a strongly typed collection of Employee objects called EmployeeCollection and the Employee object exposes a property for departmentCode. I need to do some processing on employees belonging to specific departments so I though I'd have a method that would expose a filtered view of the collection. After some digging it looks like I need to implement my own Enumeration class using IEnumerator. Can someone point me to some good code samples on how to achieve this?
I'm using VS.NET 2003
Thanks
Last edited by Mr.No; Oct 20th, 2007 at 11:39 AM.
Reason: change title
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Oct 20th, 2007, 11:40 AM
#2
Thread Starter
Fanatic Member
Re: [02/03] Enumerating a subset of a strongly typed collection
I got a mail alert that jmcilhinney replied to my post but I don't see t here
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Oct 20th, 2007, 06:57 PM
#3
Re: [02/03] Enumerating a subset of a strongly typed collection
I recommended that you implement the IBindingListView interface in another class, which I have done myself to provide sorting and filtering of a typed Collection. I then realised that you're on .NET 1.1 and that interface is new in .NET 2.0, so I deleted my post.
-
Oct 21st, 2007, 07:11 AM
#4
Thread Starter
Fanatic Member
Re: [02/03] Enumerating a subset of a strongly typed collection
jmcilhinney, thanks for taking time to respond to my post.
Until I find the right way I have added an overloaded GetEnumertor method that takes department code as argument. I then initialise an EmployeeCollection object to which I add the employees who form part of the departmentcode. An the end of the method I return the newEmpCol.GetEnumerator object.
I don't quite like the idea of building another list, I would have thought of something that would have built and returned a virtual list of indexese that match the department code.
Thanks
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Oct 21st, 2007, 07:54 AM
#5
Re: [02/03] Enumerating a subset of a strongly typed collection
Building another list is no big deal because you aren't copying the actual objects, just the references to them. That's no different to returning a list of indices as far as resources are concerned.
Last edited by jmcilhinney; Oct 21st, 2007 at 07:59 AM.
-
Oct 21st, 2007, 10:37 AM
#6
Thread Starter
Fanatic Member
Re: [02/03] Enumerating a subset of a strongly typed collection
Thanks, you re-assure me in my design then.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|