Enumerations and extension methods

Whilst making some modifications to toepoke last night I needed to do some work around the membership.  Things like Is this user a member of this squad, Have they been verified, etc. 

I started off with a statement with too many logical ORs kicking around and thought there must be a better way of expressing what I wanted to do. 

My first thought was to use Extension methods which I’ve used extensively for making my queries a little more understandable.  Could we use extension methods for the enumerations too?

My hunch was it wouldn’t work as traditionally you couldn’t add additional behaviour to an Enum.  However it turns out it’s quite straightforward:

Posted in : code, development, techie-stuff

Written by
Founder, Developer, tea maker