当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Using JSON webtoken (JWT) to generate token in nodejs
- 应用层软件开发教父教你如何重构,资深程序员必备专业技能
- September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
- Nanjing logo design and production, guide VI system design
- 2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
- 如何使用甘特图图层和筛选器
- Logo design company, Nanjing
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
- Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
猜你喜欢

2020年新规,微信封号怎么快速解除?

Stm32f030c6t6 compatible to replace mm32spin05pf

ImageMagick - add watermark

JS string - string string object method

Configuration of AP hotspot on xunwei-imx6ull development board

.NETCore3.1+Vue.js打造的低代码工作流引擎
![Yum [errno 256] no more mirrors to try solution](/img/3b/00bc81122d330c9d59909994e61027.jpg)
Yum [errno 256] no more mirrors to try solution

CI / CD of gitlab continuous integrated development environment

Exclusive interview with Yue Caibo

List to map (split the list according to the key, and the value of the same key is a list)
随机推荐
Dynamsoft barcode reader v7.5!
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
QT audio and video development 46 video transmission UDP version
2020-08-15: under what circumstances should data tasks be optimized?
Jenkins pipline stage setting timeout
PHP backdoor hiding skills
VARCHART XGantt入门教程
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
Mobile pixel adaptation scheme
Do you really know how to use search engines?
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
2020-11-06:go中,谈一下调度器。
测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
Insomnia all night
Chinese sub forum of | 2020 PostgreSQL Asia Conference: Pan Juan
关于DevOps的七大误解,99%的人都曾中过招!
ImageMagick - add watermark
git 提交规范
Bluetooth broadcast chip for Shanghai giant micro
2020-08-17: how to solve data skew in detail?