lundi 21 décembre 2015

C# expression, VS converts enum to int but not LinqPad

Suppose this fairly simple expression:

Expression<Func<DayOfWeek, bool>> filter = d => d == DayOfWeek.Friday;

In LinqPad I get an UnaryExpression for the right part, which is what I want, so I can work with the enum value and type:

Expected result in LinqPad

However, in a VS, I get a totally different ConstantExpression which converts the value to an integer:

Result in VS

I really have no clue why this is happening. Is there a global setting I'm missing in VS or something?

It happens in VS 2015 AND 2010 as well.





Aucun commentaire:

Enregistrer un commentaire