Friday, February 3, 2012

what is this thing called?

I wish I understood the = () => operator one uses with Func in C#. I don't even know what it is called. It seems that you may prep a Func within a class (in this case DateHelper) like so:

public static Func<DateTime> Now = () => DateTime.UtcNow;

 
 

...and then sort of override it by way of a monkey patch like so in another situation (in this case in a test):

DateHelper.Now = () => new DateTime(2000, 1, 1);

No comments:

Post a Comment