如果增加/减少,做一些事情

时间:2014-03-22 01:21:39

标签: c# if-statement

我想检查整数是增加还是减少,然后再做一些事情。

int x = 0;

int y = 0;

如果x值增加,y --;

谢谢!

1 个答案:

答案 0 :(得分:2)

//loop starts
//X gets modified
if(X>tempX)
{
    //X increments
}    
else if (X<tempX)
{
    //X decrements 
}
else
    //X remains the same

int tempX=X;
//loop ends