开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜