我有要转换为C#的JS代码。由于某种原因,我的C#方法返回的值比JS函数的返回值小10。我尝试更改多个内容并检查&&JS中运算符的含义,但似乎无法弄清楚我在做什么错。
正确的返回值为97。
JavaScript功能和用法:
function rir(t, e, c, n) {
return t > e
&& t <= c
&& (t += n % (c - e)) > c
&& (t = t - c + e),
t
}
rir('a'.charCodeAt(0), 47, 57, 'b'.charCodeAt(0));
/* returns 97 */
C#方法和用法:
public int Rir(int t, int e, int c, int n)
{
if (t > e && t <= c)
t += (n % (c - e));
if (t > c)
t = ((t - c) + e);
return t;
}
Rir((int)'a', 47, 57, (int)'b');
/* returns 87 */
明月笑刀无情
相关分类