当前位置:网站首页>C enumerates the differences between permissions |, and |
C enumerates the differences between permissions |, and |
2020-11-07 16:49:00 【attachment】
using System;
namespace EnumFlags
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Permissions per = Permissions.Insert | Permissions.Update| Permissions.Insert;
Console.WriteLine(per.ToString());
Permissions allP = (Permissions)Enum.Parse(typeof(Permissions),"3");
Console.WriteLine(allP);
Permissions pers = Permissions.Update;
if ((pers & Permissions.Insert) == Permissions.Insert)
{
Console.WriteLine("hava");
}
if (pers.HasFlag(Permissions.Insert))
{
Console.WriteLine("hava");
}
Console.WriteLine(1 | 2); // 01 | 10 => 11 (3)
Console.WriteLine(2 | 4); // 010 | 100 => 110 (6)
Console.WriteLine(2 | 2);
Console.WriteLine(1 & 2); // 01 & 10 => 00 (0)
Console.WriteLine(2 & 4); // 010 & 100 => 000 (0)
Console.WriteLine(2 & 2);
Console.WriteLine(1 ^ 2); // 01 ^ 10 => 11 (3)
Console.WriteLine(2 ^ 4); // 010 ^ 100 => 110 (6)
Console.WriteLine(2 ^ 2);
Console.WriteLine(condition1() | condition2() | condition3() | condition4());
Console.WriteLine("|");
Console.WriteLine(condition1() || condition2() || condition3() || condition4());
Console.WriteLine("||");
Console.WriteLine(condition1() & condition2() & condition3() & condition4());
Console.WriteLine("&");
Console.WriteLine(condition1() && condition2() && condition3() && condition4());
Console.WriteLine("&&");
}
static bool condition1()
{
Console.WriteLine("condition1()...");
return true; // perhaps false
}
static bool condition2()
{
Console.WriteLine("condition2()...");
return false; // perhaps true
}
static bool condition3()
{
Console.WriteLine("condition3()...");
return true; // perhaps false
}
static bool condition4()
{
Console.WriteLine("condition4()...");
return false; // perhaps true
}
[Flags]
public enum Permissions
{
Insert = 1,
Delete = 2,
Update = 4,
Query = 8
}
}
}
https://www.cnblogs.com/itsone/p/10310644.html
https://www.cnblogs.com/steden/p/4605768.html
https://zhuanlan.zhihu.com/p/94590467
版权声明
本文为[attachment]所创,转载请带上原文链接,感谢
边栏推荐
- 课堂练习
- Exclusive interview with Yue Caibo
- Characteristics of magnetic memory chip STT-MRAM
- 如何才能快速正确的部署甘特图
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- 汽车维修app开发的好处与功能
- How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
- Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
- CI / CD of gitlab continuous integrated development environment
猜你喜欢

pc端与移动端适配解决方案之rem

嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王旭

Idea activation to 2089 failure

And how to solve the conflict between pop-up menu and pop-up menu

The use of Xunwei imx6 development board device tree kernel menuconfig

A kind of super parameter optimization technology hyperopt
![yum [Errno 256] No more mirrors to try 解决方法](/img/3b/00bc81122d330c9d59909994e61027.jpg)
yum [Errno 256] No more mirrors to try 解决方法

Experiment one

如何才能快速正确的部署甘特图

汽车维修app开发的好处与功能
随机推荐
How to use Gantt chart layers and filters
.NETCore3.1+Vue.js打造的低代码工作流引擎
Jenkins pipline stage setting timeout
The advantages and functions of psychological counseling app
高速公路二维码定位报警系统
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
失眠一个整晚上
confd
9.集群之间服务通信 RoutingMesh
And how to solve the conflict between pop-up menu and pop-up menu
Git SSH bad permissions
如何创建交互式内核密度图表
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
A kind of super parameter optimization technology hyperopt
小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
C語言重點——指標篇(一文讓你完全搞懂指標)| 從記憶體理解指標 | 指標完全解析
Gantt chart grouping activities tutorial
7. Swarm builds clusters
如何使用甘特图图层和筛选器