What does '^' do in c# (Enums)?

前端 未结 4 863
不思量自难忘°
不思量自难忘° 2021-01-12 02:40

I was reading some 3rd party code and I found this:

x.Flags = x.Flags ^ Flags.Hidden;

What does it do?

I\'ve used \'&\' and \'|

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 03:07

    Taken from here:

    For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if an odd number of its operands is true.

提交回复
热议问题