Pop quiz: how do you ensure that a number is negative? You could do something like:
if (count > 0) {
count = count * -1
}
Or you could use a ternary:
count = count > 0 ? count * -1 : count;
Or, if you're feeling fancy, use absolute value, like
count = Math.Abs(count) * -1;
If you're Justin's coworker, however, that's not good enough. No, what you REALLY want to do is coerce to a string, prepend a negative sign, then remove any double-negatives to make a positive again:
if (count > 0 || count < 0)
{
string tCountDelta = "-" + count;
tCountDelta = tCountDelta.Replace("--", "");
// Some time later...
int countDelta = int.Parse(tCountDelta);
}
Now that's fancy.
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!