473,568 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1240
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 "containmen t by ownership" making
Car
an example of a composite class.

Containment can also be accomplished using references to external
objects.
"Containmen t 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2908
by: Nice Chap | last post by:
Aggregation in COM was defined as 'Exposing an interface of an inner object by the outer object as though it were an interface of the outer object'. Is this type of aggregation possible in c#? For example... Class COuter - 'Contains' an instance variable of type CInner Class CInner - Implements IList Can COuter be made to look...
4
10958
by: cmrchs | last post by:
Hi, how do I implement aggregation and how composition in C# ? When I say : an Airplane has a Pilot then I use aggregation but when I say : an Airplane has a Cockpit then I use composition. How do I implement the difference in C# ? Here's what I try : class Pilot
2
2617
by: Jozsef Bekes | last post by:
Hi, I would like to implement aggregation in C#, therefore I'd need to implement the queryinterface COM function of a class. I am not sure whether this can be done, and if yes where to start. If someone has an example, a hint or anything that might help, please share it with me. Thanks and Regards, Jozsi
4
14440
by: Frederik Vanderhaegen | last post by:
Hi, Can anyone explain me the difference between aggregation and composition? I know that they both are "whole-part" relationships and that composition parts are destroyed when the composition whole is destroyed. Under a "whole-part" relationship I understand the following: the whole can't exists without the parts, but can the parts exist...
23
2109
by: SenthilVel | last post by:
Hi Can any one let me know the websites/Pdf for learning Aggragation in C#?? Thanks Senthil
0
992
by: Dave Johnson | last post by:
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
5
2115
by: Dave Johnson | last post by:
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
0
1235
by: Karigar | last post by:
I have been so far developing COM servers and clients in C++. I am new to C#/NET way of doing COM and was wondering if it is possible to accomplish aggregation in .NET platform. By aggregation I mean classic COM aggregation in which the outer object controls which interfaces it of inner object it exposes, and to the outside world it appears as...
6
7833
by: Jeff | last post by:
hey Can OO Aggregation be described as: - A system of objects that are built using each other any comments? Jeff
0
7692
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7913
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7659
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2099
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.