Welcome to the Mosh Hamedani C# Intermediate Exercises repository! This project contains hands-on implementations of key object-oriented programming principles and .NET concepts, helping you solidify your understanding through real-world examples.
- Abstraction & Encapsulation: Exercises like
StopWatch
andStackOverflowPost
classes demonstrate clean interfaces and controlled access to internal state. - Inheritance & Polymorphism: Custom implementations of
Stack
(LIFO) and database connections (DbConnection
,MsSqlConnection
,OracleConnection
) showcase class hierarchies and dynamic behavior. - Interfaces & Design Principles: A flexible
WorkflowEngine
andIActivity
interfaces illustrate SOLID principles (Single Responsibility, Open/Closed, Interface Segregation). - Robust Error Handling: Consistent use of exceptions and validation for safe, predictable execution.
- Interactive Console Menu: Choose and run exercises interactively via
Program.cs
.
├── src/
│ ├── StopWatch.cs # Simulates a stopwatch with Start, Stop, Reset
│ ├── StackOverflowPost.cs # Models a StackOverflow post with voting
│ ├── Stack_LIFO.cs # Implements a generic LIFO stack
│ ├── DbConnection.cs # Abstract DB connection and command execution
│ ├── WorkflowEngine.cs # Defines workflows and activities via interfaces
│ └── Program.cs # Console entry point with menu to run exercises
├── App.config # Configuration for database examples
└── MoshHamedani_Csharp_imtermediate.sln
- .NET Framework: 4.7.2
- IDE: Visual Studio 2022 or later (Windows)
- Clone the repository
git clone https://github.com/your-username/MoshHamedani-CSharp-Intermediate.git
- Open the solution file in Visual Studio:
cd MoshHamedani-C-Sharp-Intermediate MoshHamedani_Csharp_imtermediate.sln
- Build the solution (ensure targeting .NET Framework 4.7.2).
- Run the application (F5). You will see a menu prompting you to select an exercise.
Upon running, enter the corresponding number to execute an exercise:
Option | Exercise |
---|---|
1 |
StopWatch demo (abstraction, TimeSpan) |
2 |
StackOverflowPost demo (encapsulation, properties) |
3 |
Custom Stack (LIFO) demo (inheritance, data structures) |
4 |
DbConnection & DbCommand demo (polymorphism, DB IO) |
5 |
WorkflowEngine demo (interfaces, SOLID principles) |
Contributions are welcome! Feel free to:
- Add new exercises or improve existing ones.
- Enhance exception handling and test coverage.
- Submit pull requests with clear descriptions and use cases.
This project is for educational purposes. Feel free to use and adapt the code for your own learning.
Need any additional details or tweaks? Let me know!