方程式每隔两行更改一次

Jon*_*s T 2 html c# asp.net math

我们想要做的是更改表格中行的背景颜色.每隔两行就会改变颜色.

Our id sequence is simple as follow:
id = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,.....etc.

1,2 rows -> black
3,4 rows -> white
5,6 rows -> black
7,8 rows -> white
9,10 rows -> black
11,12 rows -> white
13,14 rows -> black
15,16 rows -> white
17,18 rows -> black
etc....

if(id==1) || (id==2) class="black";
if(id==3) || (id==4) class="white";
if(id==5) || (id==6) class="black";
if(id==7) || (id==8) class="white";
if(id==9) || (id==10) class="black";
if(id==11) || (id==12) class="white";
etc.....
Run Code Online (Sandbox Code Playgroud)

根据该id值,我们如何更改黑色或白色?

非常感谢.

Mar*_*k H 12

bool white = ((rowId - 1) & 2) == 2;
Run Code Online (Sandbox Code Playgroud)