当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- The advantages and functions of psychological counseling app
- How to use Gantt chart layers and filters
- Stm32f030c6t6 compatible to replace mm32spin05pf
- September 3, 2020: naked writing algorithm: loop matrix traversal.
- confd
- 使用RabbitMQ实现分布式事务
- 三步轻松理解Kerberos协议
- Win7 how to quickly type CMD and get to the required directory
- August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
猜你喜欢
About Devops seven misunderstandings, 99% of people have been hit!
Points to be considered when deleting mapping field of index in ES
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
8.Swarm创建维护和水平扩展Service
QT audio and video development 46 video transmission UDP version
Composition of MRAM cache
.NETCore3.1+Vue.js打造的低代码工作流引擎
How to use Gantt chart layers and filters
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
7. Swarm builds clusters
随机推荐
如何才能快速正确的部署甘特图
2020-08-20: the difference between go and python?
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
VARCHART XGantt入门教程
图像处理工具包ImagXpress使用教程,如何查看事件
Detailed software engineering -- the necessary graphs in each stage
如何解决谷歌Chrome浏览器空白页的问题
C# 枚举权限 |和||,&和&&的区别
11. Service update
ImageMagick - add watermark
Dynamsoft barcode reader v7.5!
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
FreeSWITCH视频会议“标准”解决方案
STlink下载出现st-link usb communication error解决方法
Git SSH bad permissions
如何创建交互式内核密度图表
win7如何快速打cmd并到达所要的目录
Git submission specification
confd
confd