
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are the difference between Composition and Aggregation in C#?
Under Composition, if the parent object is deleted, then the child object also loses its status. The composition is a special type of Aggregation and gives a part-of relationship.
For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.
public class Engine { . . . } public class Car { Engine eng = new Engine(); ....... }
Aggregation is a directional relation between objects in C#. It is the relationship between objects.
For example, Employee and Address
An Employee is associated with a single Department, whereas a Department can have more than one employee. Let us see an example of Employee and Address −
public class Address { . . . } public class Employee { private Address addr; public Employee (Address addr) { this.addr = addr; } . . . }
- Related Articles
- Difference between composition and aggregation
- Difference Between Aggregation and Composition
- Association, Composition and Aggregation in C#
- Composition vs Aggregation in C#
- Association, Composition and Aggregation in Java\n
- Difference Between Aggregation and Association
- Difference between Association and Aggregation in Java
- Difference between inheritance and composition in Java
- Difference Between Platelet Agglutination and Aggregation
- What is aggregation in C#?
- What is composition in C#?
- What is the difference Between C and C++?
- What is the difference between | and || operators in c#?
- What are the difference between accounting and auditing?
- What is the difference between JavaScript and C++?

Advertisements