c# - Best way to determine if an expression is a constant expression -


which 1 prefer testing if expression constantexpression? nodetype property or cast, , why?

    public static bool isconstantexpression(expression expression)     {         return expression.nodetype == expressiontype.constant;         return expression constantexpression;     } 

one difference expression.nodetype == expressiontype.constant throw exception if expression null. i'm pretty sure constantexpression nullable, statement valid still.


Comments