How to use the Factory Design Pattern with C#
The factory method is a design pattern that can be used in your .NET projects to support dependency injection and therefore testable classes while also keeping your components decoupled from external dependencies.
You can dive deeper into the uses of the design pattern at the Wikipedia article. The video below shows a simple example of creating a testable class with an external dependency that can be mocked. It then shows how to create a factory class to hide the external dependency from a client component.