什么是'^'在C#(枚举)呢? [英] What does '^' do in c# (Enums)?

查看:142
本文介绍了什么是'^'在C#(枚举)呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读一些第三方的代码,我发现这一点:

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 '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol...

推荐答案

^是在C#中按位异或操作符。

^ is the bitwise XOR operator in C#.

编辑:如果是真,b为假或^ B返回true,如果是假的,b是真实的,但不能同时

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

这篇关于什么是'^'在C#(枚举)呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆