|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
The old Structure/Class Argumentto build linked lists in memory of items that were represented by a group of variables. For example, Friend Structure foo Dim var1 As String Dim var2 As Integer Dim var3 As Boolean End Structure I needed several structures, each with a different mix of number of members and the datatypes. Now, these structures could have been implemented as classes. But I do not know how multiple instances of a class can be linked together so I can process them in a standard For Each/Next loop. I see one guideline of whether to use a Class or a Structure is if the Structure is less or equal to 16 bytes. Several of these structures will be larger than that, so I am open to converting the code to use classes instead of structures if someone can give me some pointers on how to link instances of a class together. TIA, Use a collection
Tom za***@construction-imaging.com wrote: Show quoteHide quote >I recently wrote a VB.NET application using VS2005. I needed to be able >to build linked lists in memory of items that were represented by a >group of variables. For example, > >Friend Structure foo > Dim var1 As String > Dim var2 As Integer > Dim var3 As Boolean >End Structure > >I needed several structures, each with a different mix of number of >members and the datatypes. Now, these structures could have been >implemented as classes. But I do not know how multiple instances of a >class can be linked together so I can process them in a standard For >Each/Next loop. > >I see one guideline of whether to use a Class or a Structure is if the >Structure is less or equal to 16 bytes. Several of these structures >will be larger than that, so I am open to converting the code to use >classes instead of structures if someone can give me some pointers on >how to link instances of a class together. > >TIA, > > > I am. A collection of structures.
Sorry, I forgot to mention that. I would prefer to use multiple instances of a class to emulate a collection but I can't figure out how to link the multiple instances. Well if i see your structure i would say just leave it as a structure as it
would only hurt the performance of your app to convert this to a class Basically, classes are reference types and structs are value types. Reference types get stored differently than value types. Value types are stored more efficiently on the stack vs classes on the heap using structures will also save the GC some trips :-) as it does not need to reclaim memory want to know in detail when to use a class or when to use a structure ??? watch this video http://msdn.microsoft.com/netframework/programming/classlibraries/richtypesystem/ regards Michel Posseth [MCP] <za***@construction-imaging.com> schreef in bericht Show quoteHide quote news:1137167240.183905.106040@o13g2000cwo.googlegroups.com... >I recently wrote a VB.NET application using VS2005. I needed to be able > to build linked lists in memory of items that were represented by a > group of variables. For example, > > Friend Structure foo > Dim var1 As String > Dim var2 As Integer > Dim var3 As Boolean > End Structure > > I needed several structures, each with a different mix of number of > members and the datatypes. Now, these structures could have been > implemented as classes. But I do not know how multiple instances of a > class can be linked together so I can process them in a standard For > Each/Next loop. > > I see one guideline of whether to use a Class or a Structure is if the > Structure is less or equal to 16 bytes. Several of these structures > will be larger than that, so I am open to converting the code to use > classes instead of structures if someone can give me some pointers on > how to link instances of a class together. > > TIA, > Zacks,
I assume that you a List wants of those. http://msdn2.microsoft.com/en-us/library/6sh2ey19(en-us,VS.80).aspx Although that I never use a structure and would use a class \\\ Friend Structure foo Dim var1 As String Dim var2 As Integer Dim var3 As Boolean End Structure Private mylist As New List(Of foo) /// I hope this helps, Cor Is a List better than a Collection?
You mention that you would use a class, but in your example code you used a structure. Can you: Class foo <define each member of the former structure as a property> End Structure Private mylist As New List(Of foo) (Thanks for the pointer to the new List class, anyway. I will research it) > (To integrate your sample)> You mention that you would use a class, but in your example code you > used a structure. Can you: > Yes, Yes (however not end structure but end class) see the link I gave > Class foo > <define each member of the former structure as a property> > End Structure > Private mylist As New List(Of foo) > > (Thanks for the pointer to the new List class, anyway. I will research > it) there is very much information. I hope this helps, Cor
Impossible? Who called the Method?
RTF How to make Windows inaccessible from my software user? Help Migrating From ListBox to ListView: Only One Problem DATE HELLLPPPP 64 bit operating systems ClickOnce Deployment questions MS Application Updater Block BindingSource for a class - need a light bulb moment |
|||||||||||||||||||||||