Skip to content

Instantly share code, notes, and snippets.

@PhiHuyHoang
Created September 12, 2018 21:10
Show Gist options
  • Save PhiHuyHoang/7b68895b3d59229a2029899924064677 to your computer and use it in GitHub Desktop.
Save PhiHuyHoang/7b68895b3d59229a2029899924064677 to your computer and use it in GitHub Desktop.
method constructor function example C#
Action<string> logMethods;
public void AddLogMethod(Action<string> newLogMethod)
{
logMethods += newLogMethod;
}
public void LogThis(string msg)
{
logMethods?.Invoke($"[{DateTime.Now.ToLongDateString()}] {msg}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment