PC Review


Reply
Thread Tools Rate Thread

Creating Collections in Classes

 
 
=?Utf-8?B?QW5vbnltb3Vz?=
Guest
Posts: n/a
 
      15th Feb 2005
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.
 
Reply With Quote
 
 
 
 
VBen
Guest
Posts: n/a
 
      15th Feb 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" <(E-Mail Removed)> escribió en el mensaje
news:164889E6-54D4-4801-B777-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
=?Utf-8?B?QW5vbnltb3Vz?=
Guest
Posts: n/a
 
      15th Feb 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" <(E-Mail Removed)> escribió en el mensaje
> news:164889E6-54D4-4801-B777-(E-Mail Removed)...
> > 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.

>
>
>

 
Reply With Quote
 
VBen
Guest
Posts: n/a
 
      15th Feb 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" <(E-Mail Removed)> escribió en el mensaje
news:0DF7A55F-2B41-4BA0-BA51-(E-Mail Removed)...
> 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" <(E-Mail Removed)> escribió en el mensaje
> > news:164889E6-54D4-4801-B777-(E-Mail Removed)...
> > > 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.

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?QW5vbnltb3Vz?=
Guest
Posts: n/a
 
      17th Feb 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/de...ionobjects.asp

Here's another excellent site on the same topic:

http://www.informit.com/guides/conte...net&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" <(E-Mail Removed)> escribió en el mensaje
> news:0DF7A55F-2B41-4BA0-BA51-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> escribió en el mensaje
> > > news:164889E6-54D4-4801-B777-(E-Mail Removed)...
> > > > 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.
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
represent XML in classes/collections (C#) Bart Steur Microsoft Dot NET 3 24th Sep 2008 05:09 PM
represent XML in classes/collections (C#) Bart Steur Microsoft C# .NET 3 24th Sep 2008 05:09 PM
Classes and Collections Neal Ostrander Microsoft Access VBA Modules 2 23rd Jul 2008 07:17 PM
Inheriting VB6 dll classes/collections into dotnet classes/collections =?Utf-8?B?Q2hhcmxlcw==?= Microsoft Dot NET Framework 0 30th Apr 2004 02:56 PM
classes and collections =?Utf-8?B?c29ja2E=?= Microsoft Access ADP SQL Server 2 16th Feb 2004 11:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:58 AM.