0

Here is my code:

private decimal _WeightedScoreProfitibility;

[PersistentAlias("WeightProfitibility.WeightNumber * ScoreProfitibility.ScoreNumber")]
public decimal? WeightedScoreProfitibility 
{
    get
    {
        try
        {
            return decimal.Parse(EvaluateAlias("WeightedScoreProfitibility").ToString());
        }
        catch ( NullReferenceException )
        {
            return 0;
        }
    }
}

I was getting an Object Null Reference on the my getter. I am assuming because the fields I am calculating in the Persistent Alias are 0 values.

I am catching the null reference error and now when i run the app It just hangs and spins. it never loads. How do I handle this null reference exception when the values I am calculating in the persistent alias are 0?

Wai Ha Lee
  • 7,664
  • 52
  • 54
  • 80
EB.
  • 2,373
  • 8
  • 32
  • 46
  • `EvaluateAlias("WeightedScoreProfitaibility")` is returning `null`. Find out why using a debugger and fix it. Alternatively, you can check if the value returned is `null` and if it is, do something else. See [this question](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) for more information. – clcto Mar 05 '15 at 20:56
  • 3
    Why `decimal?` if you don't return `null`? – crashmstr Mar 05 '15 at 21:00

0 Answers0