我们要做的是改变表格中行的背景颜色。颜色将每隔两行改变一次。
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.....
根据该 id 值,我们如何将颜色更改为黑色或白色?
非常感谢。
最佳答案
bool white = ((rowId - 1) & 2) == 2;
关于c# - 每隔两行更改一次的方程式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6829129/