1

I'm working on standard page and what is the best way to cast any 0.00 to null check? I have a situation where I want to check to see if the decimal value is 0.00 but is that consider to be a best practice if I have something like this:

if(reading == 0.00) { //its null }
  • Can you please provide more context? Where in the controller/extension are you doing this? – Adrian Larson May 28 '15 at 19:18
  • @AdrianLarson: its more of a generic question or approach then context and I do not have much code to show you other than what I have here... so bascially its a check to see reading is null or not. – Nick Kahn May 28 '15 at 19:21
  • why would you downvote any explanation? – Nick Kahn May 28 '15 at 19:28
  • 2
    Not I with the downvote. – Adrian Larson May 28 '15 at 19:30
2

The general verb I tend to for this process is to elide:

public static Decimal elide(Decimal value)
{
    return (value == 0) ? null : value;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.