Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > BOOK: Professional .NET 2.0 Generics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional .NET 2.0 Generics
This is the forum to discuss the Wrox book Professional .NET 2.0 Generics by Tod Golding; ISBN: 9780764559884
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional .NET 2.0 Generics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 20th, 2011, 04:52 PM
Authorized User
Points: 139, Level: 2
Points: 139, Level: 2 Points: 139, Level: 2 Points: 139, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Spokane, WA, USA.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generic collection works but has quirks

This test collection uses what could be called an "inner list." One quirk is that the ADD uses the InsertItem routine in the test class instead of the default (internal) .Add shown by debugging. INSERT uses the class InsertItem as expected. But INDEXOF does not use the class IndexOf and it returns -1 even though the "December" item is in the collection.
Public Class WinterMonth
Private _monthOf As String
Public Property MonthOf() As String
Return _monthOf
End Get
Set (ByVal value as String)
_monthOf = value
End Set
End Property
Public Sub New(ByVal monthOf As String)
Me.MonthOf = monthOf
End Sub
End Class
Public Class WinterMonths(Of T)
Inherits Collection(Of T)
Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As T)
End Sub
Protected Overloads Sub IndexOf(ByVal item as T)
End Sub
End Class
Protected Sub Page_Load etc.
Dim winter As New WinterMonths(Of WinterMonth)
winter.Add(New WinterMonth("January"))
winter.Insert(0, New WinterMonth("December"))
winter.Add(New WinterMonth("February"))
winter.Insert(winter.Count, New WinterMonth("March"))
Dim idx = winter.IndexOf(New WinterMonth("December"))
monthlist.DataSource = winter
monthlist.DataValueField = "MonthOf"
End Sub
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2, system.collection.generic.list Ziaulhassan BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 January 2nd, 2010 03:51 AM
How can i make this generic girija45701 C# 0 November 29th, 2008 04:32 AM
Databinding a Generic Collection to a Datagrid rolandatem ASP.NET 2.0 Professional 0 October 7th, 2006 11:08 PM
Generic collection population from database micmit C# 2005 7 September 19th, 2006 05:53 AM
DateTime format quirks ADMystery ASP.NET 1.0 and 1.1 Professional 5 September 18th, 2006 06:02 AM

All times are GMT -4. The time now is 07:26 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.