C#: How can I make an integer negative?
How can I make an integer negative in C#?
abc = 5开发者_JS百科645307;
// how to make abc -5645307 ?
Maybe I'm missing something:
abc = -abc;
If you want it to be negative whether it was negative beforehand or not, you would use:
abc = -Math.Abs(abc);
This is how you can convert your int value to minus in c#
abc = abc > 0 ? abc*(-1) : abc;
how about....
xyz = Math.Abs(xyz) * (-1)
精彩评论