|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GenericsPublic Class ACollection(Of T) Inherits BindingList(Of T) where BaseDataClass is declared mustinherit i then have some code that loadss the collection With oSQLDR ' a datareader If .HasRows Then Do While .Read = True 'Create new instance of appropriate businees object then populate Dim o As Object = Me.AddNew busObject = CType(o, IDataClass) busObject.clientConnection = Me.ClientConnection busObject.Populate(oSQLDR) Loop End If End With this all works fine however if i change this collection to Public Class ACollection(Of BaseCLass) how, when using AddNew in the above code do i get addnew to add the correct type of object (which inherits from BaseClass) guyy I believe you need to change your line
Dim o as Object = Me.AddNew to Dim o as T = Me.AddNew Jim Wooley Show quoteHide quote "guy" <g**@discussions.microsoft.com> wrote in message news:B21B0D32-F6EE-48C5-81B8-001C378D2C2B@microsoft.com... >i have a generic class > this all works fine > > however if i change this collection to > > Public Class ACollection(Of BaseCLass) > > how, when using AddNew in the above code do i get addnew to add the > correct > type of object (which inherits from BaseClass)
Strongly Typed Key Value Collections within a For Next loop
Problem adding new row in Access Table storing image in Access table How can I read an XML string directly into a dataset without creating a file? Can I create windows form by using late binding? HTML in to readable/value accessible object what to do, what to do Help Displaying & Stabilizing PictureBox Contents Text file printout in dos mode through VB.Net or DOS command from VB.Net Setup Project |
|||||||||||||||||||||||