c# 数据结构

来源:百度知道 编辑:UC知道 时间:2024/09/23 07:43:49
public void RecordMaze()
{
//record the configuration of the maze to the MazeInMouse during the first search
if (mazeInMouse[crtPos.i1, crtPos.j1] == 0x8F)//to see whether the cell has been visited before
{
mazeInMouse[crtPos.i1, crtPos.j1] = 0x00;
mazeInMouse[crtPos.i1, crtPos.j1] = maze[crtPos.i1, crtPos.j1];
mazeInMouse[crtPos.i1, crtPos.j1] |= 0x10;
}
}

mazeInMouse[crtPos.i1, crtPos.j1] |= 0x10;这句什么意思 “|=”这个符号

你明白+=这个是什么意思吗?
x+=y 意思是x=x+y

x|=y 意思是 x=x|y ,其中| 表示按位或,是位运算操作

表示 mazeInMouse[crtPos.i1, crtPos.j1]=mazeInMouse[crtPos.i1, crtPos.j1] | 0x10;
相当于一个赋值语句。将mazeInMouse[crtPos.i1, crtPos.j1] 与0x10按位取或 然后赋值给mazeInMouse[crtPos.i1, crtPos.j1]