This is a simple C# console application that demonstrates the use of generics, abstract classes, and interfaces in an inventory management context. The system supports adding, removing, and listing products from different categories such as electronic and food products.
-
Models/
BaseProduct: Abstract base class with common properties (Id, Name, Price, Stock).ElectronicProduct: Inherits fromBaseProductand represents electronic items.FoodProduct: Inherits fromBaseProductand represents food items.
-
Services/
IInventoryService<T>: A generic interface defining common inventory operations.InventoryService<T>: A generic class that implementsIInventoryServicefor product management.
-
Program.cs
- Demonstrates adding, removing, and displaying products.
- Add electronic and food products to a generic inventory
- Remove products from inventory
- List all products with details
- Uses inheritance and generic constraints for clean and reusable code
- Language: C#
- Platform: .NET (Console Application)
- Concepts Used:
- Generics
- Interfaces
- Abstract Classes
- Object-Oriented Programming (OOP)