Reputation: 14044
Can somebody help me to write this in C# code?
Let's say I have:
int x = 7;
int y = 10;
Now I want to check that if(x should be in the range of -3 / +3 == y should be in the range of -3 / +3)
so on both the side I have a range to check. I hope I am clear enough.
Let me put this in other words.
if (range(x,3) == range(y,3))
In this case it should check all the whether any of the number in x
range is contained by y
.
Upvotes: 0
Views: 86
Reputation: 1203
You could use Math
library. A simple method would do the trick:
if (Math.Abs(x-y)<=3)
Upvotes: 1