Monday, December 17, 2012

Converting Enum to List in C#

This is an easy but recurrent question that I end searching on Google from time to time. So to adhere to this blog's motto and not searching it again here's the solution:

Enum.GetValues(typeof(SomeEnum)).Cast();

(The original solution thread at stackoverflow)

Tuesday, December 4, 2012

NCalc: a mathematical expressions evaluator in .NET


For a project that I've been developing lately I needed to evaluate some mathematical expressions that I'll store as text strings. So my first thought was like "I'm not the first man on earth with such necessity, ergo, it must have been accomplished by someone else before me". That is a thought that I have in a lot of situations, but fortunately this time it turned out to be truth.

As the CodePlex project's page states: "NCalc is a mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions".

IMHO is an excellent tool, but to be fair, I'm not doing nothing overly complicated in my project.