471,334 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Most Simple Aggregation

greetings,

can any one show sample example of aggregation in any .net code vb.net
or C#

i guess it shouldnt be that hard but i searched a lot without finding
anything that explains the issue in code. thanks for your reply
Sharing makes All the Difference

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Jan 16 '06 #1
1 1182
Containment represents a HAS_A relationship between the whole and a
part.
So a car IS_A motorized vehicle, but HAS_A radio. The two relationships
can
be expressed in code thusly:

class Radio
{
...
}
class Vehicle
{
...
}
class Car : Vehicle
{
Radio r= new Radio();
}
An instance of Car contains an instance of a Radio so that the lifetimes
of the
radio and car are intertwined. This is "containment by ownership" making
Car
an example of a composite class.

Containment can also be accomplished using references to external
objects.
"Containment by reference" can be expressed in code thusly:

class Radio
{
...
}
class Vehicle
{
...
}
class Car : Vehicle
{
private Radio r;
public Car(Radio r) {
...
this.r= r;
}
}
You can then create an instance of Car like this:

class Class1
{
[STAThread]
static void Main(string[] args)
{
Radio r= new Radio();
Car c= new Car(r);
}
}

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nice Chap | last post: by
4 posts views Thread by cmrchs | last post: by
2 posts views Thread by Jozsef Bekes | last post: by
4 posts views Thread by Frederik Vanderhaegen | last post: by
23 posts views Thread by SenthilVel | last post: by
reply views Thread by Dave Johnson | last post: by
5 posts views Thread by Dave Johnson | last post: by
reply views Thread by Karigar | last post: by
6 posts views Thread by Jeff | last post: by

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.