Changing bool values to opposite of the initial value

后端 未结 7 672
天命终不由人
天命终不由人 2021-01-03 19:05

This maybe sound strange to you but I\'m too lazy to write everytime like

if (threadAlive)
{
            threadAlive = false;
}
        else
{
            th         


        
7条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 20:03

    This would do it:

    threadAlive = !threadAlive;
    

    The correct term is Toggle

提交回复
热议问题