Full Notes on C#.NET, Lecture notes of System Programming

.NET is a free, open-source framework developed by Microsoft for building various types of applications. It provides a programming model, runtime environment, and a vast library of pre-built code components that simplify the development process. .NET supports multiple programming languages, including C#, Visual Basic, and F#, allowing developers to choose the language they are most comfortable with.

Typology: Lecture notes

2022/2023

Available from 06/27/2023

Pintu112
Pintu112 🇮🇳

5 documents

1 / 53

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Notes on C#.NET
Notes by Pintu Giri
1
Introduction to .NET
.NET is a free, open-source framework developed by Microsoft for building various types of
applications. It provides a programming model, runtime environment, and a vast library of pre-
built code components that simplify the development process. .NET supports multiple
programming languages, including C#, Visual Basic, and F#, allowing developers to choose
the language they are most comfortable with.
The key components of .NET are:
1. Common Language Runtime (CLR): The CLR is the execution engine that runs .NET
applications. It provides services such as memory management, security, and exception
handling. The CLR ensures that applications written in different .NET languages can
interoperate seamlessly.
2. Base Class Library (BCL): The BCL is a collection of reusable classes, interfaces, and value
types that provide a wide range of functionality. It includes classes for working with files,
databases, network communication, user interfaces, and much more. The BCL saves
developers time by offering pre-built components for common tasks.
3. Framework Class Library (FCL): The FCL is an extended version of the BCL that includes
additional libraries for building specific types of applications, such as ASP.NET for web
development, Windows Forms for desktop applications, and WPF (Windows Presentation
Foundation) for creating rich graphical user interfaces.
4. Language Interoperability: .NET languages, such as C#, VB.NET, and F#, share a common
runtime environment, allowing code written in one language to be used by another. This
interoperability enables developers to leverage existing code and libraries regardless of the
language they were written in.
5. Integrated Development Environment (IDE): Microsoft provides Visual Studio, a powerful
IDE for developing .NET applications. Visual Studio offers features like code editing,
debugging, and project management, making it easier for developers to write, test, and deploy
their applications.
6. Cross-platform Development: With the introduction of .NET Core, which is a cross-
platform version of .NET, developers can build applications that run on various operating
systems, including Windows, macOS, and Linux. This enables code reuse and deployment
flexibility across different platforms.
7. Web Development: ASP.NET is a popular framework within .NET for building web
applications. It provides various tools and libraries for creating dynamic websites, web APIs,
and web services. ASP.NET supports multiple development models, including Web Forms,
MVC (Model-View-Controller), and Razor Pages.
8. Community and Ecosystem: .NET has a vibrant developer community and a vast ecosystem
of third-party libraries and frameworks. This ecosystem provides additional tools and resources
to enhance productivity and extend the capabilities of .NET applications.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Full Notes on C#.NET and more Lecture notes System Programming in PDF only on Docsity!

Notes on C#.NET

Introduction to .NET

.NET is a free, open-source framework developed by Microsoft for building various types of applications. It provides a programming model, runtime environment, and a vast library of pre- built code components that simplify the development process. .NET supports multiple programming languages, including C#, Visual Basic, and F#, allowing developers to choose the language they are most comfortable with. The key components of .NET are:

  1. Common Language Runtime (CLR): The CLR is the execution engine that runs .NET applications. It provides services such as memory management, security, and exception handling. The CLR ensures that applications written in different .NET languages can interoperate seamlessly.
  2. Base Class Library (BCL): The BCL is a collection of reusable classes, interfaces, and value types that provide a wide range of functionality. It includes classes for working with files, databases, network communication, user interfaces, and much more. The BCL saves developers time by offering pre-built components for common tasks.
  3. Framework Class Library (FCL): The FCL is an extended version of the BCL that includes additional libraries for building specific types of applications, such as ASP.NET for web development, Windows Forms for desktop applications, and WPF (Windows Presentation Foundation) for creating rich graphical user interfaces.
  4. Language Interoperability: .NET languages, such as C#, VB.NET, and F#, share a common runtime environment, allowing code written in one language to be used by another. This interoperability enables developers to leverage existing code and libraries regardless of the language they were written in.
  5. Integrated Development Environment (IDE): Microsoft provides Visual Studio, a powerful IDE for developing .NET applications. Visual Studio offers features like code editing, debugging, and project management, making it easier for developers to write, test, and deploy their applications.
  6. Cross-platform Development: With the introduction of .NET Core, which is a cross- platform version of .NET, developers can build applications that run on various operating systems, including Windows, macOS, and Linux. This enables code reuse and deployment flexibility across different platforms.
  7. Web Development: ASP.NET is a popular framework within .NET for building web applications. It provides various tools and libraries for creating dynamic websites, web APIs, and web services. ASP.NET supports multiple development models, including Web Forms, MVC (Model-View-Controller), and Razor Pages.
  8. Community and Ecosystem: .NET has a vibrant developer community and a vast ecosystem of third-party libraries and frameworks. This ecosystem provides additional tools and resources to enhance productivity and extend the capabilities of .NET applications.

Notes on C#.NET Overall, .NET is a versatile and comprehensive framework for developing a wide range of applications, from small console utilities to large-scale enterprise solutions. It offers developers a powerful set of tools, language choices, and cross-platform capabilities, making it a popular choice for building modern applications.

Constructors in C#.NET

Object-oriented programming is all about writing the code inside classes. A class is a collection of various numbers like fields methods constructors etc etcetera and in that one of the most important members that is present in a class is going to be called as a constructor. A constructor is responsible to initialize the variables inside your class. Each and every class requires this constructor if we want to create the instance of the class, but here we are creating the instance but we do not have anything called as a constructor. If this is valid, the last point what we are here discussing does not make any sense why without that constructor we are telling instance cannot be created. Implicit constructors are also known as default constructors. Default constructors mean a constructor which does not take any parameters. Implicit constructors can be parameter less or parametrized. Explicit constructors may also be called explicit constructors or parameter less constructors. Implicit constructors which are defined implicitly are public. The solution explorer adds a new class only in the classes’ explicit condom. Explicit condom. Implicit constructors cannot be parameterized Implicit constructor or parameter less. Explicit constructors are parameterised or parameterised. Explicit constructors can be parameterised and parameterised also two options are there for us. Whenever the instance of a class is created then there is an implicit call to the appropriate constructor. When we call the constructor, the implicit constructor is a called and will call and will initialize the variables which variables i and b with a 0 and false. The first program is a class and the second program is your constructor means you are calling the constructor explicitly. A constructor means implementing one constructor in your class so this is called defining. Defining means we are explicitly writing the code for the appropriate and that’s called defining can be two types of calling. A calling must be done explicitly by us if you do not call the constructor explicitly that is not going to execute that may be an implicit constructor.

Types of Constructors in C#.NET

There are the three types of constructors in C#.NET. Constructors are special methods that are called automatically when an object is created. They are responsible for initializing the object's state.

1. Default Constructor:

A default constructor is automatically generated by the compiler if no constructor is defined explicitly. It has no parameters and initializes the object with default values. It is used to create an object without passing any arguments. For example:

public class MyClass

// Default constructor

Notes on C#.NET parameters to a constructor, you can ensure that the necessary dependencies are provided when an object is created. This promotes loose coupling and improves testability and maintainability of the code.

  1. Custom Initialization Logic: Constructors enable you to perform custom initialization logic based on specific requirements or conditions. You can execute code within the constructor to set default values, validate inputs, establish connections, or perform any other necessary operations.
  2. Overloading: Constructors can be overloaded, which means you can define multiple constructors with different parameter sets. This allows you to create objects with different initialization options or accommodate various usage scenarios.
  3. Object Creation: Constructors are responsible for creating instances of a class. When you use the new keyword to create an object, a constructor is called to allocate memory and initialize the object. Overall, constructors are essential in a class as they provide a way to initialize objects, manage dependencies, and execute necessary setup operations. They ensure that objects are created in a valid and usable state, and they contribute to the overall design and functionality of the class.

Differences between Variable Instance and Reference

In C#, there is a distinction between variables that hold value types (variables of value type) and variables that hold reference types (variables of reference type). Here are the differences between the two:

  1. Value Types:
    • Variables of value types directly store the actual data values.
    • When a value type variable is assigned to another variable or passed as a parameter, a copy of the value is made.
    • Modifying the copied value does not affect the original value.
    • Value types include built-in types such as int, float, bool, and structs.
  2. Reference Types:
    • Variables of reference types hold references to objects in memory rather than the actual data.
    • When a reference type variable is assigned to another variable or passed as a parameter, the reference (memory address) is copied, not the actual object data.
    • Modifying the object through one reference affects all other references pointing to the same object.
    • Reference types include classes, interfaces, delegates, and string. Additional differences between value types and reference types include:
  3. Memory Allocation:
    • Value types are typically allocated on the stack, which is more efficient in terms of memory access and deallocation.
    • Reference types are allocated on the heap, which provides more flexibility in terms of memory management and object lifetime.
  4. Nullability:

Notes on C#.NET

  • Value types cannot be assigned the value of null. They always have a default value (e.g., 0 for int, false for bool).
  • Reference types can be assigned the value of null, indicating that they do not reference any object.
  1. Default Initialization:
  • Value types are automatically initialized with their default values when declared.
  • Reference types are initialized with the value of null by default when declared.
  1. Equality Comparison:
  • Value types are compared by their actual values, checking if the values are equal.
  • Reference types are compared by reference, checking if two references point to the same object (unless overridden by custom equality logic). Understanding the differences between value types and reference types is crucial for correctly managing and manipulating data in C#. It affects variable behaviour, memory usage, and assignment semantics.

Access Specifiers in C#.Net

In C#.NET, access specifiers are keywords used to specify the accessibility or visibility of types (classes, structs, interfaces, enums) and their members (fields, properties, methods, constructors). These access specifiers control how these types and members can be accessed from other parts of the code. The following are the access specifiers available in C#.NET:

  1. Public (public): o Public access specifiers allow types and members to be accessed from any part of the program, both within the defining class and from external classes. o Example: public class MyClass { }, public int myField;
  2. Private (private): o Private access specifiers restrict the accessibility of types and members to only within the containing class. o They cannot be accessed from other classes or code outside the defining class. o Example: private int myField;, private void MyMethod() { }
  3. Protected (protected): o Protected access specifiers allow types and members to be accessed within the defining class and derived classes (subclasses). o They are not accessible from external classes or code outside the class hierarchy. o Example: protected int myField;, protected void MyMethod() { }
  4. Internal (internal): o Internal access specifiers allow types and members to be accessed within the same assembly (DLL or executable). o They are not accessible from external assemblies. o Example: internal class MyClass { }, internal int myField;

Notes on C#.NET

  • They are implicitly static and are shared among all instances of the class.
  • Constant variables must be initialized at the time of declaration and cannot be modified later.
  • Example: private const double pi = 3.14;, public const int maxAttempts = 3;
  1. Readonly Variables:
  • Readonly variables are declared with the readonly keyword and can have different values for each instance of the class.
  • They can be assigned a value either at the time of declaration or in the class constructor, but cannot be modified afterwards.
  • Readonly variables provide flexibility to set their values at runtime but prevent modification once initialized.
  • Example: private readonly DateTime creationTime;, public readonly string defaultLanguage; These are the common types of variables that can be present in a class. Each type serves a specific purpose, such as storing object-specific data, maintaining shared data, or holding constant values. Understanding these variable types and their characteristics is important for proper data management and encapsulation within a class.

What’s Inheritance

Inheritance is a fundamental concept in object-oriented programming (OOP) that allows one class to inherit the properties, methods, and behaviour of another class. It establishes a parent- child relationship between classes, enabling code reuse and creating a hierarchical structure in the program. Inheritance is based on the principle of specialization and generalization. A class that inherits from another class is called a derived class or subclass, and the class it inherits from is called the base class or superclass. The derived class inherits all the members (fields, properties, methods) of the base class, which means it can use and extend them without duplicating code. The key benefits of inheritance include:

  1. Code Reusability: Inheritance allows you to define common attributes and behaviour in a base class and reuse them in multiple derived classes. This reduces code duplication and promotes efficient development and maintenance.
  2. Extensibility: Derived classes can add new members or override inherited members to modify or extend the behaviour inherited from the base class. This enables customization and specialization of functionality while leveraging existing code.
  3. Polymorphism: Inheritance plays a vital role in achieving polymorphism, which is the ability to treat objects of derived classes as objects of their base class. Polymorphism allows you to write code that can work with different objects through a common interface, enhancing flexibility and modularity.

Notes on C#.NET To establish inheritance between classes in C#, you use the colon (:) symbol followed by the name of the base class after the derived class declaration. For example: public class MyBaseClass { // Base class members } public class MyDerivedClass : MyBaseClass { // Derived class members } The derived class can then access and use the inherited members from the base class, as well as add its own members or override the inherited ones. Inheritance is a powerful mechanism in OOP that promotes code reuse, modularity, and flexibility. It allows you to create class hierarchies, define specialized behaviour, and build complex systems by extending existing classes.

Inheritance: net framework

Inheritance in .NET Framework follows the same principles and concepts as inheritance in object-oriented programming (OOP). The .NET Framework is a software framework developed by Microsoft that provides a vast collection of libraries, tools, and runtime environments for building various types of applications. In the .NET Framework, you can use inheritance to create class hierarchies and establish relationships between classes. The key features and concepts related to inheritance in the .NET Framework include:

  1. Class Inheritance:
    • You can define class hierarchies by using inheritance in the .NET Framework.
    • A class can inherit from another class, known as the base class or superclass, using the : symbol.
    • The derived class, also called the subclass, automatically inherits the members (fields, properties, methods) of the base class and can extend or modify them as needed.
    • Inheritance promotes code reuse and provides a way to organize and structure your classes based on their relationships.
  2. Access Modifiers:
    • The .NET Framework supports various access modifiers (public, private, protected, internal, etc.) to control the accessibility of inherited members.
    • Access modifiers determine whether the members can be accessed by other classes or code outside the class hierarchy.
    • By using access modifiers, you can enforce encapsulation and control the visibility and accessibility of inherited members.
  3. Inheritance and Polymorphism:

Notes on C#.NET

5. .NET Framework 4.5 and later: Subsequent versions of the .NET Framework continued to enhance and refine inheritance-related features, performance, and compatibility with newer language features and frameworks. It's important to note that the .NET Framework has been succeeded by .NET Core, which has evolved into the open-source and cross-platform .NET 5 and later .NET versions. These newer versions have also introduced advancements related to inheritance, such as improved support for single file applications, runtime components, and performance optimizations. Overall, while inheritance itself does not have specific versions, programming languages and frameworks that support inheritance may introduce changes and improvements related to inheritance over different versions or releases to enhance its functionality and usability.

Inheritance new features

Inheritance is a fundamental concept in object-oriented programming, and new features related to inheritance are typically introduced at the language level rather than as specific features of inheritance itself. The features introduced in newer versions of programming languages often enhance the capabilities and usage of inheritance. Here are some examples of new features and enhancements related to inheritance in popular programming languages: C#:

  1. Generics: Introduced in C# 2.0, generics enable the creation of type-safe classes, methods, and interfaces that can work with different data types. This allows for more flexible and reusable code using inheritance.
  2. Extension Methods: C# 3.0 introduced extension methods, which allow adding new methods to existing classes without modifying their source code. This feature can be used to extend the functionality of base classes through inheritance.
  3. Default Interface Methods: C# 8.0 introduced default interface methods, enabling the addition of method implementations in interfaces. This feature improves the capability of interfaces to define shared behavior, reducing the need for abstract base classes. Java:
  4. Default Methods: Java 8 introduced default methods in interfaces, which allow the addition of method implementations directly in interfaces. This feature enhances the capability of interfaces to provide default behavior to implementing classes, reducing the need for abstract base classes.
  5. Lambda Expressions: Java 8 also introduced lambda expressions, which facilitate the use of functional interfaces. Functional interfaces can be used in inheritance to define single-method interfaces that can be implemented by derived classes.
  6. Records: Java 14 introduced records, which are classes that provide automatic implementations of equals(), hashCode(), and toString() methods based on their state. Records can be used in inheritance hierarchies to define immutable data classes more concisely.

Notes on C#.NET Python:

  1. Multiple Inheritance: Python supports multiple inheritance, allowing a class to inherit from multiple base classes. This feature provides flexibility in building class hierarchies and enables the reuse of code from multiple sources.
  2. Method Resolution Order (MRO): Python defines a specific order in which base classes are searched when resolving method calls in a class hierarchy. The MRO algorithm ensures that inherited methods are resolved in a consistent and predictable manner. These are just a few examples of new features and enhancements related to inheritance in programming languages. The specific features and enhancements available may vary depending on the programming language and its version.

Types of inheritance

In object-oriented programming, inheritance allows classes to inherit properties and behaviour from other classes. There are several types of inheritance that define different relationships between classes. The common types of inheritance are:

1. Single Inheritance: o Single inheritance involves a class inheriting from a single base class. o A derived class extends the functionality of the base class, inheriting all its members (fields, properties, methods). o Single inheritance forms a linear hierarchy, where each derived class has only one direct base class. 2. Multiple Inheritance: o Multiple inheritance allows a class to inherit from multiple base classes. o The derived class incorporates features from multiple parent classes, inheriting their members. o Multiple inheritance can introduce complexity, such as ambiguity when two or more base classes define the same member. Some languages, like C#, do not support multiple inheritance directly, but offer alternatives like interfaces to achieve similar effects. 3. Multilevel Inheritance: o Multilevel inheritance involves a chain of inheritance with multiple levels of classes. o A derived class becomes the base class for another class, forming a hierarchical structure. o Each derived class inherits the members of its immediate base class, and the inheritance chain can be extended to multiple levels. 4. Hierarchical Inheritance: o Hierarchical inheritance occurs when multiple classes inherit from a single base class. o Multiple derived classes inherit the same members and behaviour from a common base class. o Each derived class can extend or modify the inherited members independently.

Notes on C#.NET } } public class MainClass { public static void Main() { Dog dog = new Dog(); dog.Eat(); // Inherited from Animal class dog.Bark(); // Defined in Dog class } } In this example, the Animal class is the base class, and the Dog class is the derived class. The Dog class inherits the Eat() method from the Animal class and adds its own unique method, Bark(). Through single inheritance, the Dog class exhibits both the common behaviour of an animal (eating) and its specific behaviour (barking).

Hybrid inheritance

Hybrid inheritance is a type of inheritance that combines multiple types of inheritance, such as single inheritance and multiple inheritance, in object-oriented programming (OOP). It involves inheriting properties, methods, and behaviour from both base classes and interfaces. In hybrid inheritance, a class can inherit from one or more base classes (single inheritance) and implement one or more interfaces. This allows the derived class to combine the characteristics and functionality of multiple classes and interfaces, forming a hybrid inheritance structure. By using hybrid inheritance, a class can benefit from code reuse, modularity, and the ability to define both general and specialized behaviour. It provides flexibility in creating complex class hierarchies and allows classes to have multiple types of relationships with other classes and interfaces. It's important to note that not all programming languages support hybrid inheritance directly. Some languages, such as C++, allow for multiple inheritance, where a class can inherit from multiple base classes simultaneously. Other languages, such as Java and C#, do not support multiple inheritance but provide interfaces to achieve similar effects. In these languages, a class can implement multiple interfaces while maintaining single inheritance with a base class. Here's an example in C++ to illustrate hybrid inheritance using multiple inheritance: class Animal { public: void eat() { cout << "Animal is eating." << endl; } }; class Mammal { public:

Notes on C#.NET void giveBirth() { cout << "Mammal is giving birth." << endl; } }; class Dog : public Animal, public Mammal { public: void bark() { cout << "Dog is barking." << endl; } }; int main() { Dog dog; dog.eat(); // Inherited from Animal class dog.giveBirth(); // Inherited from Mammal class dog.bark(); // Defined in Dog class return 0; } In this example, the Dog class inherits from both the Animal class and the Mammal class, representing multiple inheritance. It also defines its own method, bark(). The Dog class exhibits characteristics of both an animal (eating) and a mammal (giving birth) through hybrid inheritance.

Multiple Inheritance

Multiple inheritance is a feature in some object-oriented programming languages that allows a class to inherit properties, methods, and behaviour from multiple base classes. In other words, a class can have more than one direct parent class. With multiple inheritance, a derived class inherits members from multiple base classes, allowing it to combine and integrate the features and behaviours of those classes. The derived class can access and use the members from all the base classes as if they were defined within the derived class itself. Multiple inheritance can provide flexibility and code reuse by allowing a class to inherit and incorporate features from different sources. It allows the creation of complex class hierarchies and facilitates the modelling of real-world relationships where a class exhibits characteristics of multiple entities. It's important to note that not all programming languages support multiple inheritance directly. Some languages, such as C++, allow for multiple inheritance by allowing a class to inherit from multiple base classes simultaneously. Other languages, such as Java and C#, do not support multiple inheritance but provide alternatives like interfaces or mixins to achieve similar effects. Here's an example in C++ to illustrate multiple inheritance: class Animal { public:

Notes on C#.NET Here's an example in C# to illustrate multilevel inheritance: public class Animal { public void Eat() { Console.WriteLine("Animal is eating."); } } public class Mammal : Animal { public void GiveBirth() { Console.WriteLine("Mammal is giving birth."); } } public class Dog : Mammal { public void Bark() { Console.WriteLine("Dog is barking."); } } public class MainClass { public static void Main() { Dog dog = new Dog(); dog.Eat(); // Inherited from Animal class dog.GiveBirth(); // Inherited from Mammal class dog.Bark(); // Defined in Dog class } } In this example, the Animal class is the base class, and the Mammal class derives from the Animal class. The Dog class then derives from the Mammal class. Each derived class inherits the members of its immediate base class, forming a multilevel inheritance structure. The Dog class exhibits the behaviour of an animal (eating), a mammal (giving birth), and adds its own behaviour (barking) through multilevel inheritance.

Hierarchical Inheritance

Hierarchical inheritance is a type of inheritance in object-oriented programming (OOP) where multiple derived classes inherit from a single base class. In other words, it involves creating a hierarchy of classes with a common base class and multiple derived classes.

Notes on C#.NET In hierarchical inheritance, the base class serves as a common ancestor for multiple derived classes. Each derived class inherits all the members (fields, properties, methods) from the base class and can also add its own unique members or override inherited members. Hierarchical inheritance allows for the specialization and differentiation of classes based on their specific characteristics or behaviours. Each derived class can extend or modify the inherited members according to its specific requirements, while still retaining the common functionality inherited from the base class. Hierarchical inheritance promotes code reuse and provides a way to model relationships and hierarchies in a system. It allows for the creation of a class hierarchy where each derived class represents a distinct specialization or variation of the base class. Here's an example in C# to illustrate hierarchical inheritance: public class Shape { public virtual void Draw() { Console.WriteLine("Drawing a shape."); } } public class Circle : Shape { public override void Draw() { Console.WriteLine("Drawing a circle."); } } public class Rectangle : Shape { public override void Draw() { Console.WriteLine("Drawing a rectangle."); } } public class Triangle : Shape { public override void Draw() { Console.WriteLine("Drawing a triangle."); } } public class MainClass { public static void Main()

Notes on C#.NET { public void Draw() { Console.WriteLine("Drawing a circle."); } } public class Rectangle : IShape { public void Draw() { Console.WriteLine("Drawing a rectangle."); } } public class MainClass { public static void Main() { IShape circle = new Circle(); circle.Draw(); // Drawing a circle IShape rectangle = new Rectangle(); rectangle.Draw(); // Drawing a rectangle } } In this example, the IShape interface defines the Draw() method signature that any implementing class must provide. The Circle and Rectangle classes implement the IShape interface and provide their own implementations for the Draw() method. Through interface inheritance, we can create instances of the Circle and Rectangle classes using the IShape interface type. This allows us to treat different shapes interchangeably based on their shared capability of being able to draw.

What is Entity in Inheritance

In the context of inheritance, an entity refers to a class or object that serves as a base or parent class from which other classes or derived entities inherit properties, methods, and behaviour. Inheritance allows entities to establish a hierarchical relationship, where the derived entities inherit the attributes and behaviours defined in the base entity. The base entity, often referred to as the superclass or parent class, provides a common set of characteristics and functionality that can be shared among its derived entities, also known as subclasses or child classes. The derived entities inherit the attributes and methods of the base entity, allowing them to reuse code and extend or modify the inherited behaviour to suit their specific needs. This promotes code reuse, modularity, and allows for the creation of specialized entities that inherit common characteristics from a shared base entity.

Notes on C#.NET Entities in inheritance form a hierarchical structure, with the base entity at the top and multiple derived entities branching out below it. Each derived entity inherits and adds its own unique features to the inherited attributes and methods, forming a specialized version of the base entity. Here's a simplified example in C# to illustrate entity inheritance: public class Animal { public string Species { get; set; } public void Eat() { Console.WriteLine("Animal is eating."); } } public class Dog : Animal { public void Bark() { Console.WriteLine("Dog is barking."); } } public class Cat : Animal { public void Meow() { Console.WriteLine("Cat is meowing."); } } public class MainClass { public static void Main() { Dog dog = new Dog(); dog.Species = "Canine"; dog.Eat(); // Inherited from Animal class dog.Bark(); // Defined in Dog class Cat cat = new Cat(); cat.Species = "Feline"; cat.Eat(); // Inherited from Animal class cat.Meow(); // Defined in Cat class } } In this example, the Animal class is the base entity, and the Dog and Cat classes are derived entities that inherit from the Animal class. Both Dog and Cat inherit the Species attribute and the Eat() method from the Animal class. Additionally, each derived entity adds