Error 2 Operator '+' cannot be applied to operands of type 'decimal' and 'double'

Not sure what this means.  Can someone point me in the right direction?

Here is my code:

            if (reader.HasRows)
                id = Convert.ToDecimal(reader["id"].ToString());

                id = id + .0001;-----------------------------------------------------------Error Occurs Here
                Session.Add("id", id);
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
this will work better:
id = id + (decimal).0001;

Open in new window

Guy Hengel [angelIII / a3]Billing EngineerCommented:
or shorter:
id += (decimal).0001;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kwh3856OwnerAuthor Commented:
your awesome but your title already shows that;)......congrats on that new title.

Kevin CrossChief Technology OfficerCommented:
Angel's answer is the right one, but in the spirit of making shorter, you can do this as well.

id += .0001m;

Open in new window

actually mwvisa1 your answer is correct and here is why ....

id = id + (decimal) .0001;

says ...

id is equal to id plus the conversion of the double value .0001 to a decimal.

id += .0001m; or id = id + .0001m;

says ...

id is equal to id plus .0001

While these two may SEEM to be equivalent they are not because of how floating point math works on computers. Since floating point numbers are handled by approximations ... on some machines (or some JIT implementations) you may end up with a scenario where the first bit of code for an id of 1 returns


where the second one would return


For more details I would suggest reading


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.