In: microsoft.public.dotnet.framework.performance
Hi, can someone give links either in msdn.microsoft.com or other sites that
tell me what are the best ways to create Collection properties in a class
written in Visual Basic.NET?

Eg., say I create a Class that instantiated allows you to get a property of
collections: Forms.Controls, TreeView.Nodes etc etc.

In my work, I only used ArrayList to create Collections but want to try
other interface classes such iCollection, hasttables, etc etc.

Thanks in advance.

Re: Creating Collections in Classes by VBen

VBen
Tue Feb 15 14:11:15 CST 2005

You have to inherit from one of the collection classes you mention, and
override the methods you want... I don't know where to get a sample of this,
since I'm not in my computer right now, but there's a sample in "101 VB.Net
Samples" (if you can google it).
Here's a sample (of course, I haven't compiled it, and it will not run
unless you complete it, but it gives you an idea):

Public Class MyClass
'...Properties and Methods...
Public sub New ()
'TODO:assign default values
End Sub
Public Sub New (PropA as Integer, PropB as Integer)
'TODO:assign values to the new object
End Sub
Public Property MyPropA () as Integer
'TODO:Inner implementation of the property
End Property
Public Property MyPropB () as String
'TODO:Inner implementation of the property
End Property
End Class
Public Class MyCollection
Inherits Hashtable '(for example)
Public Overrides Overloads Sub Add (key as Object, o as object)
MyBase.Add(key, o)
End Sub
Public Overloads Sub Add (key as Object, PropA as Integer, PropB as
String)
Mybase.Add(key, new MyClass(PropA, PropB))
End Sub
'etc...
End Class

If you need a wider sample, contact me (to my e-mail) and I'll send you a
sample when I get home.
Hope this helps.
VBen.

"Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
news:164889E6-54D4-4801-B777-4D84EF746500@microsoft.com...
> In: microsoft.public.dotnet.framework.performance
> Hi, can someone give links either in msdn.microsoft.com or other sites
that
> tell me what are the best ways to create Collection properties in a class
> written in Visual Basic.NET?
>
> Eg., say I create a Class that instantiated allows you to get a property
of
> collections: Forms.Controls, TreeView.Nodes etc etc.
>
> In my work, I only used ArrayList to create Collections but want to try
> other interface classes such iCollection, hasttables, etc etc.
>
> Thanks in advance.



Re: Creating Collections in Classes by Anonymous

Anonymous
Tue Feb 15 14:23:07 CST 2005

Hi, VBen. Thanks a lot for your sample. That's great code.

Is there a site that describes fully the pros and cons of using which
Collection class, etc? I remember there were articles in msdn.microsoft.com
about this matter (it also include performance issues of these classes; eg.,
you should not use inherit the iComparable class if your class barely use
sorts since iComparable is an unnecessary resource hog, etc.)

Thanks.


"VBen" wrote:

> You have to inherit from one of the collection classes you mention, and
> override the methods you want... I don't know where to get a sample of this,
> since I'm not in my computer right now, but there's a sample in "101 VB.Net
> Samples" (if you can google it).
> Here's a sample (of course, I haven't compiled it, and it will not run
> unless you complete it, but it gives you an idea):
>
> Public Class MyClass
> '...Properties and Methods...
> Public sub New ()
> 'TODO:assign default values
> End Sub
> Public Sub New (PropA as Integer, PropB as Integer)
> 'TODO:assign values to the new object
> End Sub
> Public Property MyPropA () as Integer
> 'TODO:Inner implementation of the property
> End Property
> Public Property MyPropB () as String
> 'TODO:Inner implementation of the property
> End Property
> End Class
> Public Class MyCollection
> Inherits Hashtable '(for example)
> Public Overrides Overloads Sub Add (key as Object, o as object)
> MyBase.Add(key, o)
> End Sub
> Public Overloads Sub Add (key as Object, PropA as Integer, PropB as
> String)
> Mybase.Add(key, new MyClass(PropA, PropB))
> End Sub
> 'etc...
> End Class
>
> If you need a wider sample, contact me (to my e-mail) and I'll send you a
> sample when I get home.
> Hope this helps.
> VBen.
>
> "Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
> news:164889E6-54D4-4801-B777-4D84EF746500@microsoft.com...
> > In: microsoft.public.dotnet.framework.performance
> > Hi, can someone give links either in msdn.microsoft.com or other sites
> that
> > tell me what are the best ways to create Collection properties in a class
> > written in Visual Basic.NET?
> >
> > Eg., say I create a Class that instantiated allows you to get a property
> of
> > collections: Forms.Controls, TreeView.Nodes etc etc.
> >
> > In my work, I only used ArrayList to create Collections but want to try
> > other interface classes such iCollection, hasttables, etc etc.
> >
> > Thanks in advance.
>
>
>

Re: Creating Collections in Classes by VBen

VBen
Tue Feb 15 15:13:35 CST 2005

I'm not aware of any site, besides MSDN. (msdn.microsoft.com or
www.msdn.com)
If you find any, please let me know, since I work with collections a lot,
inherited ones, and would like to be able to take a more accurate decission
in which base collection class to use...
Thank you.
VBen.

"Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
news:0DF7A55F-2B41-4BA0-BA51-2DE1AE734B88@microsoft.com...
> Hi, VBen. Thanks a lot for your sample. That's great code.
>
> Is there a site that describes fully the pros and cons of using which
> Collection class, etc? I remember there were articles in
msdn.microsoft.com
> about this matter (it also include performance issues of these classes;
eg.,
> you should not use inherit the iComparable class if your class barely use
> sorts since iComparable is an unnecessary resource hog, etc.)
>
> Thanks.
>
>
> "VBen" wrote:
>
> > You have to inherit from one of the collection classes you mention, and
> > override the methods you want... I don't know where to get a sample of
this,
> > since I'm not in my computer right now, but there's a sample in "101
VB.Net
> > Samples" (if you can google it).
> > Here's a sample (of course, I haven't compiled it, and it will not run
> > unless you complete it, but it gives you an idea):
> >
> > Public Class MyClass
> > '...Properties and Methods...
> > Public sub New ()
> > 'TODO:assign default values
> > End Sub
> > Public Sub New (PropA as Integer, PropB as Integer)
> > 'TODO:assign values to the new object
> > End Sub
> > Public Property MyPropA () as Integer
> > 'TODO:Inner implementation of the property
> > End Property
> > Public Property MyPropB () as String
> > 'TODO:Inner implementation of the property
> > End Property
> > End Class
> > Public Class MyCollection
> > Inherits Hashtable '(for example)
> > Public Overrides Overloads Sub Add (key as Object, o as object)
> > MyBase.Add(key, o)
> > End Sub
> > Public Overloads Sub Add (key as Object, PropA as Integer, PropB as
> > String)
> > Mybase.Add(key, new MyClass(PropA, PropB))
> > End Sub
> > 'etc...
> > End Class
> >
> > If you need a wider sample, contact me (to my e-mail) and I'll send you
a
> > sample when I get home.
> > Hope this helps.
> > VBen.
> >
> > "Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
> > news:164889E6-54D4-4801-B777-4D84EF746500@microsoft.com...
> > > In: microsoft.public.dotnet.framework.performance
> > > Hi, can someone give links either in msdn.microsoft.com or other sites
> > that
> > > tell me what are the best ways to create Collection properties in a
class
> > > written in Visual Basic.NET?
> > >
> > > Eg., say I create a Class that instantiated allows you to get a
property
> > of
> > > collections: Forms.Controls, TreeView.Nodes etc etc.
> > >
> > > In my work, I only used ArrayList to create Collections but want to
try
> > > other interface classes such iCollection, hasttables, etc etc.
> > >
> > > Thanks in advance.
> >
> >
> >



Re: Creating Collections in Classes by Anonymous

Anonymous
Wed Feb 16 20:31:04 CST 2005

Hi, Ben. Can't believe this but it took me a long time to find the link I
mentioned in MSDN site! Here it is:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingmanipulatingcollectionobjects.asp

Here's another excellent site on the same topic:

http://www.informit.com/guides/content.asp?g=dotnet&seqNum=120

"VBen" wrote:

> I'm not aware of any site, besides MSDN. (msdn.microsoft.com or
> www.msdn.com)
> If you find any, please let me know, since I work with collections a lot,
> inherited ones, and would like to be able to take a more accurate decission
> in which base collection class to use...
> Thank you.
> VBen.
>
> "Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
> news:0DF7A55F-2B41-4BA0-BA51-2DE1AE734B88@microsoft.com...
> > Hi, VBen. Thanks a lot for your sample. That's great code.
> >
> > Is there a site that describes fully the pros and cons of using which
> > Collection class, etc? I remember there were articles in
> msdn.microsoft.com
> > about this matter (it also include performance issues of these classes;
> eg.,
> > you should not use inherit the iComparable class if your class barely use
> > sorts since iComparable is an unnecessary resource hog, etc.)
> >
> > Thanks.
> >
> >
> > "VBen" wrote:
> >
> > > You have to inherit from one of the collection classes you mention, and
> > > override the methods you want... I don't know where to get a sample of
> this,
> > > since I'm not in my computer right now, but there's a sample in "101
> VB.Net
> > > Samples" (if you can google it).
> > > Here's a sample (of course, I haven't compiled it, and it will not run
> > > unless you complete it, but it gives you an idea):
> > >
> > > Public Class MyClass
> > > '...Properties and Methods...
> > > Public sub New ()
> > > 'TODO:assign default values
> > > End Sub
> > > Public Sub New (PropA as Integer, PropB as Integer)
> > > 'TODO:assign values to the new object
> > > End Sub
> > > Public Property MyPropA () as Integer
> > > 'TODO:Inner implementation of the property
> > > End Property
> > > Public Property MyPropB () as String
> > > 'TODO:Inner implementation of the property
> > > End Property
> > > End Class
> > > Public Class MyCollection
> > > Inherits Hashtable '(for example)
> > > Public Overrides Overloads Sub Add (key as Object, o as object)
> > > MyBase.Add(key, o)
> > > End Sub
> > > Public Overloads Sub Add (key as Object, PropA as Integer, PropB as
> > > String)
> > > Mybase.Add(key, new MyClass(PropA, PropB))
> > > End Sub
> > > 'etc...
> > > End Class
> > >
> > > If you need a wider sample, contact me (to my e-mail) and I'll send you
> a
> > > sample when I get home.
> > > Hope this helps.
> > > VBen.
> > >
> > > "Anonymous" <Anonymous@discussions.microsoft.com> escribió en el mensaje
> > > news:164889E6-54D4-4801-B777-4D84EF746500@microsoft.com...
> > > > In: microsoft.public.dotnet.framework.performance
> > > > Hi, can someone give links either in msdn.microsoft.com or other sites
> > > that
> > > > tell me what are the best ways to create Collection properties in a
> class
> > > > written in Visual Basic.NET?
> > > >
> > > > Eg., say I create a Class that instantiated allows you to get a
> property
> > > of
> > > > collections: Forms.Controls, TreeView.Nodes etc etc.
> > > >
> > > > In my work, I only used ArrayList to create Collections but want to
> try
> > > > other interface classes such iCollection, hasttables, etc etc.
> > > >
> > > > Thanks in advance.
> > >
> > >
> > >
>
>
>