Link to home
Start Free TrialLog in
Avatar of PSCTECH
PSCTECH

asked on

Object reference not set to an instance of an object error

I have the following code which is throwing an "object reference not set to an instance of an object error".  How can I change it to not give this exception?  The code is supposed to check for SecondaryWageAmount and if it's there, add it to PrimaryWageAmount otherwise just return PrimaryWageAmount

            decimal returnValue;
            returnValue = HasSecondary ?
                               PrimaryWageAmount + SecondaryWageAmount
                            : PrimaryWageAmount;
            return returnValue;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of louisfr
louisfr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PSCTECH
PSCTECH

ASKER

Actally, I figured it out.  You are right  SecondaryWageAmount was erroneously getting set to null.  Thanks for the response
Avatar of PSCTECH

ASKER

Thanks for the quick response.  I appreciate it.
Are you certain that the error is happening on this section of code? Your exception... is it indicating that the error is on these lines?