C# - Virtual Static Void

Virtual Static Void

Keeping track of the ever changing...

Browse by Tags

All Tags » C# (RSS)
Switching on Enums
Having read Jared Parsons blog entry on Switching on Types , I was inspired to follow on with a class that switches on enumerated values. This is achievable using a regular switch, but this approach seems more elegant. The expected usage as follows: // given enumeration public enum HoldingField { Holding, BookValue, MarketValue, EffectiveExposure, } ... // code to extract result from respective property of "h" decimal result = 0m; EnumSwitch.Do ( HoldingField, EnumSwitch.Case(HoldingField...