0

I know this is a pretty simpleton question, and I have tried google first, but I'm currently stumped here. I'm clearly missing something obvious.

How do you subtract a negative integer from a byte value?

//Code simplified greatly for simple simplicity :)
byte BaseValue = 10;
int Modifer = -2;

BaseValue += Modifer; //Should end up with BaseValue = 8

I've tried declaring Modifer has a byte (can't have negatives), I've tried declaring it as a sbyte (can't cast sbyte to byte).

In this case 8 is still a valid value for a byte type so not sure why I can't subtract from it.

How do you actually do what I'm trying to do? Again, this strikes me as a dirt simple mistake but I can't seem to figure out what's going on here.

thanks

0 Answers0