473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inheritance Collection Classes

I need to have a series of collection classes that inherit (I think) from
each other. What is the best way to do this in .NET? In VB6 I had a series
of collection classes each passing a reference to the parent object down the
tree.

For example:
Customer(s) -> Email(s) -> Attachment(s)

Or maybe:
Directory -> Directory -> Directory -> Files etc

Do I still simply pass teh reference to the parent down the tree?
I also need the child classes to get information form the parent.

You also can't put:

Public Class cAttachments
Inherits System.Collections.CollectionBase
Inherits cEmail
...

Nov 20 '05 #1
4 1076
NM
Hi Andrew,

class inheritance means that :
if you have a class A that inherit class B so the class A has all class B
caracteristics (Public and Protected attributes, procedures and functions).
it's like if you say that a baby got the eyes of his father and the mouth of
his mother;

Now what you want to do (if I understand) is to have a class Customer that
have an attribute Emails (which is a class or a collection of classes) wich
have a reference to the Customer class;
To do that, create your class Emails with a constructor which take the
Customer class in parameter and store it in an Emails class attribute :

Class Emails

Protected myCustomer as Customer

Public Sub new (Byref c As Customer)
myCustomer = c
End Sub

...

End Class

Regards
"Andrew" <an*****@nospam.dbasplus.com> a écrit dans le message de
news:%2***************@TK2MSFTNGP09.phx.gbl...
I need to have a series of collection classes that inherit (I think) from
each other. What is the best way to do this in .NET? In VB6 I had a series
of collection classes each passing a reference to the parent object down the tree.

For example:
Customer(s) -> Email(s) -> Attachment(s)

Or maybe:
Directory -> Directory -> Directory -> Files etc

Do I still simply pass teh reference to the parent down the tree?
I also need the child classes to get information form the parent.

You also can't put:

Public Class cAttachments
Inherits System.Collections.CollectionBase
Inherits cEmail
...

Nov 20 '05 #2
Thanks for the response. Your right my terminology is wrong.
I was rather hoping that there would be a better way of referencing the
parent class other than passing it to the child. This is the same as VB6.
Cheers.
"NM" <NM****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi Andrew,

class inheritance means that :
if you have a class A that inherit class B so the class A has all class B
caracteristics (Public and Protected attributes, procedures and functions). it's like if you say that a baby got the eyes of his father and the mouth of his mother;

Now what you want to do (if I understand) is to have a class Customer that
have an attribute Emails (which is a class or a collection of classes) wich have a reference to the Customer class;
To do that, create your class Emails with a constructor which take the
Customer class in parameter and store it in an Emails class attribute :

Class Emails

Protected myCustomer as Customer

Public Sub new (Byref c As Customer)
myCustomer = c
End Sub

...

End Class

Regards
"Andrew" <an*****@nospam.dbasplus.com> a écrit dans le message de
news:%2***************@TK2MSFTNGP09.phx.gbl...
I need to have a series of collection classes that inherit (I think) from each other. What is the best way to do this in .NET? In VB6 I had a series of collection classes each passing a reference to the parent object down

the
tree.

For example:
Customer(s) -> Email(s) -> Attachment(s)

Or maybe:
Directory -> Directory -> Directory -> Files etc

Do I still simply pass teh reference to the parent down the tree?
I also need the child classes to get information form the parent.

You also can't put:

Public Class cAttachments
Inherits System.Collections.CollectionBase
Inherits cEmail
...


Nov 20 '05 #3
Unfortunately this does not quite solve all my problems.

I need to get information for an item in a collection from one of it's
parents.

Ie, how would you suggest I get the customer email address (assuming this is
a property) form the email item.

I need something like :
Address = theEmail.Parent.CustomerEmail
"Andrew" <an*****@nospam.dbasplus.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Thanks for the response. Your right my terminology is wrong.
I was rather hoping that there would be a better way of referencing the
parent class other than passing it to the child. This is the same as VB6.
Cheers.
"NM" <NM****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi Andrew,

class inheritance means that :
if you have a class A that inherit class B so the class A has all class B
caracteristics (Public and Protected attributes, procedures and functions).
it's like if you say that a baby got the eyes of his father and the mouth of
his mother;

Now what you want to do (if I understand) is to have a class Customer

that have an attribute Emails (which is a class or a collection of classes)

wich
have a reference to the Customer class;
To do that, create your class Emails with a constructor which take the
Customer class in parameter and store it in an Emails class attribute :

Class Emails

Protected myCustomer as Customer

Public Sub new (Byref c As Customer)
myCustomer = c
End Sub

...

End Class

Regards
"Andrew" <an*****@nospam.dbasplus.com> a écrit dans le message de
news:%2***************@TK2MSFTNGP09.phx.gbl...
I need to have a series of collection classes that inherit (I think) from each other. What is the best way to do this in .NET? In VB6 I had a series of collection classes each passing a reference to the parent object

down the
tree.

For example:
Customer(s) -> Email(s) -> Attachment(s)

Or maybe:
Directory -> Directory -> Directory -> Files etc

Do I still simply pass teh reference to the parent down the tree?
I also need the child classes to get information form the parent.

You also can't put:

Public Class cAttachments
Inherits System.Collections.CollectionBase
Inherits cEmail
...



Nov 20 '05 #4
NM

"Andrew" <an*****@nospam.dbasplus.com> a écrit dans le message de
news:es**************@TK2MSFTNGP10.phx.gbl...
Unfortunately this does not quite solve all my problems.

I need to get information for an item in a collection from one of it's
parents.

Ie, how would you suggest I get the customer email address (assuming this is a property) form the email item.
If your classes Email and Customer are defined like that :

Class Email

Public myCustomer as Customer

Public Sub new (Byref c As Customer)
myCustomer = c
End Sub

...

End Class

Class Customer

Protected myName as String
Public myEmails as ArrayList

Public sub new (byval n as String, byref emails as Arraylist)
myName = n
myEmails = emails
End Sub

Public readonly property getName () As String
Get
return myName
End Get
End property

...

End Class


I need something like :
Address = theEmail.Parent.CustomerEmail


Address = theEmail.myCustomer.myEmails

Regards
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe Delphi | last post by:
Does Visual Basic support multiple inheritance? That is one child class inheriting from more than one parent class. JD
8
by: DKode | last post by:
Ok, here is another question I have that is sort of unrelated to my last posting about composition. I have three Collection classes: EmployeeCollection HourCollection InfractionCollection
5
by: ma740988 | last post by:
Prefer composition to inheritance (can't recall which text I stole that line from) is one of the fundamental tenets thats engrained in my mind. Having said that inheritance requires careful...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: Gaetan | last post by:
hi i have 2 classes A1 and A2 implementing a problem with 2 different ways i also have 2 other classes X1 and X2 implementing an other problem i need classes that provide A1+X1 methods,...
10
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
8
by: RSH | last post by:
Hi, I am working on some general OOP constructs and I was wondering if I could get some guidance. I have an instance where I have a Base Abstract Class, and 4 Derived classes. I now need to...
4
by: EnsGabe | last post by:
Suppose you have a class heirarchy as such: class Base{ .... }; class Mid1 : public Base{ ....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.