当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- ImageMagick - add watermark
- Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
- 8.Swarm创建维护和水平扩展Service
- Experiment one
- How to optimize the decoding performance of dynamsoft barcode reader
- Points to be considered when deleting mapping field of index in ES
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
- Application of UHF RFID medical blood management system
- OpenCV計算機視覺學習(10)——影象變換(傅立葉變換,高通濾波,低通濾波)
- 20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
猜你喜欢
In 2020, how can wechat seal numbers be quickly lifted?
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
STlink下载出现st-link usb communication error解决方法
.NETCore3.1+ Vue.js Low code workflow engine
Solution to st link USB communication error in stlink Download
python3操作Jenkins模块api
Benefits and functions of auto maintenance app development
RECH8.0版本学习 days 12 rh134部分
Plug in bilibilibili new version 0.5.5
8. Swarm creates maintenance and horizontal extension service
随机推荐
2020-08-20: the difference between go and python?
confd
The advantages and functions of psychological counseling app
7.Swarm搭建集群
Detailed software engineering -- the necessary graphs in each stage
2020-08-15: under what circumstances should data tasks be optimized?
RECH8.0版本学习 days 12 rh134部分
2020-09-04: do you understand the function call convention?
How to create an interactive kernel density chart
7. Swarm builds clusters
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
How does LeadTools detect, read and write barcodes
Composition of MRAM cache
WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
Blazor 準備好為企業服務了嗎?
9. Routingmesh service communication between clusters
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
CI / CD of gitlab continuous integrated development environment
k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution