The Power of Func<>

Written By John Sonmez

I remember why I love C#.

After spending the last two years or so writing mainly Java code, getting back into Visual Studio felt a little awkward and painful.

Where did all my keyboard shortcuts go?  Why can’t I navigate to members in a class?  Oh, yes Resharper… ah that’s better.

But then it happened.

I was minding my own business writing some code… la la la

Oh my, repeated code!  What ever shall I do?

Hmm… It varies by property names only.

Surely I can refactor out the override loading code.  Can’t put it in the constructor, because the goal is to lazy load the overrides from the database.

Func<> to the rescue!

This is the power of Func.  Of delegates really.  You can’t do this in Java folks… Hold on to your chair.  Here we go…. Whee…..

Good has won…

Evil has been defeated…

Code has been deleted

Thank you Func<>

Don’t forget the Super Combo!

Also, check out the new page I created, a compilation of useful posts I have written about building software in an Agile way.