Skip to content

Instantly share code, notes, and snippets.

@maximgorbatyuk
Created October 13, 2021 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximgorbatyuk/1a6590f82547772746f5d97121869c8c to your computer and use it in GitHub Desktop.
Save maximgorbatyuk/1a6590f82547772746f5d97121869c8c to your computer and use it in GitHub Desktop.
public class BusinessService
{
private readonly ILogger _logger;
public BusinessService(ILogger logger)
{
_logger = logger;
}
public void SomeMethod()
{
_logger.Write("Hello world");
}
}
var service = new BusinessService(new ConsoleLogger());
public class ConsoleLogger : ILogger
{
public void Write(string message)
{
Console.WriteLine(message);
}
}
public interface ILogger
{
void Write(string message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment