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

前端 未结 4 824
不思量自难忘°
不思量自难忘° 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 02:59

    ^ is the bitwise XOR operator in C#.

    EDIT: a ^ b returns true if a is true and b is false or if a is false and b is true, but not both.

提交回复
热议问题