Association, Aggregation, and Composition are terms that represent relationships among objects. They are very basic stuff of Object-Oriented Programming. Association Association is a relationship among the objects. Association is "*a*" relationship among objects. In Association, the relationship among the objects determines what an object instance can cause another to perform an action on its behalf. We can also say that an association defines the multiplicity among the objects. We can define a one-to-one, one-to-many, many-to-one and many-to-many relationship among objects. Association is a more general term to define a relationship among objects. Association means that an object "uses" another object. For example, Managers and Employees, multiple employees may be associated with a single manager and a single employee may be associated with multiple managers. Aggregation Aggregation is a special type of Association. Aggregation is "*the*" relationship amo...
It is a new feature that has been added in C# 3.0 which allows us to add new methods into a class without editing the source code of the class i.e. if a class consists of a set of members in it and in the future if you want to add new methods into the class, you can add those methods without making any changes to the source code of the class. Extension methods can be used as an approach to extending the functionality of a class in the future if the source code of the class is not available or we don’t have any permission in making changes to the class. Before extension methods, inheritance is an approach that is used for extending the functionality of a class i.e. if we want to add any new members to an existing class without making a modification to the class, we will define a child class to that existing class and then we add new members in the child class. In the case of an extension method, we will extend the functionality of an existing class. In this case, we will create a new cl...
In C#, the "throw" keyword is used to throw an exception when an error occurs in your code. However, there are two variations of the "throw" statement: "throw" and "throw ex" . We will look at the distinctions between "throw" and "throw ex" in C# in this article. In C#, the "throw" keyword is used to declare an exception. When an exception is thrown, the code that can handle it uses a catch block to capture it. The "throw" keyword is typically used to throw a new exception object, which can be created using the "new" keyword. For example, look at the below code: C# Code: try { // Some code that could potentially throw an exception } catch (Exception ex) { // Handle the exception ...
Comments
Post a Comment