Friday, December 7, 2018

C# Delegate Example

A delegate is a type that represents references to methods with a particular parameter list and return type. It is a reference type variable that holds the reference to a method and the reference can be changed at runtime.

Given below is an example of implementing logging using delegate. The class is not aware of the implementation of the logging. The calling application/object can decide to implement the logging using different mechanisms - log to disk or database or make api call  etc.




No comments: