Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conversion from C# to VB.NET
Message
De
18/04/2013 02:35:02
 
 
À
17/04/2013 16:33:36
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01571173
Message ID:
01571297
Vues:
40
>Ok, here's my findings.
>
>I created a temp version of Tables:
>
>
>    Public Class TablesTemp
>        Inherits System.Collections.Specialized.NameObjectCollectionBase
>
>        Public Overloads Sub Add(ByVal Table As Table)
>            BaseAdd(Table.Name, Table)
>        End Sub
>
>        Default Public Overloads ReadOnly Property Item(ByVal Title As String) As Table
>            Get
>                Return CType(BaseGet(Title), Table)
>            End Get
>        End Property
>
>        Default Public Overloads ReadOnly Property Item(ByVal Index As Integer) As Table
>            Get
>                Return CType(BaseGet(Index), Table)
>            End Get
>        End Property
>
>        ' Removes an entry with the specified key from the collection
>        Public Sub Remove(ByVal tcKey As String)
>            BaseRemove(tcKey)
>        End Sub
>
>        ' Removes an entry in the specified index from the collection
>        Public Sub Remove(ByVal tnIndex As Integer)
>            BaseRemoveAt(tnIndex)
>        End Sub
>
>        ' Removes everything
>        Public Sub Clear()
>            BaseClear()
>        End Sub
>
>    End Class
>
>
>Then, I tried:
>
>
>oApp.Tables = oApp.TablesTemp
>
>
>This does not work as the designer is complaining:
>
>"Value of type 'Framework.Framework.TablesTemp' cannot be converted to 'Framework.Framework.Tables'. "
>
>So, I thought we are not able to assign a NameObjectCollectionBase object as is to another one. So, I implemented a cloneable interface to TablesTemp. I got:
>
>"Unable to cast object of type 'Framework.Framework.TablesTemp' to type 'Framework.Framework.Tables'."
>
>So, is this normal we cannot assign a NameObjectCollectionBase object to another one?


I said to use a tmp variable - not a tmp class

You instantiate a new Tables(), popuplate it, then assign it to App.oApp.Tables

Before assigning the new instance - everyone will access the 'older' version. After assigning it, every one will acces the newer version
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform