当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 2020-08-17: how to solve data skew in detail?
- How to add modules to nginx image?
- Git SSH bad permissions
- VARCHART XGantt入门教程
- 条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
- python3操作Jenkins模块api
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
- 2020-11-06: go, let's talk about the scheduler.
- Python 3 operates the Jenkins module API
- Mongo user rights login instruction
猜你喜欢
Stm32f030c6t6 compatible to replace mm32spin05pf
7.Swarm搭建集群
.NETCore3.1+ Vue.js Low code workflow engine
失眠一个整晚上
Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
你真的会使用搜索引擎吗?
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
Experiment one
傲視Kubernetes(一):Kubernetes簡介
STlink下载出现st-link usb communication error解决方法
随机推荐
Nonvolatile MRAM memory used in all levels of cache
How to deploy Gantt chart quickly and correctly
Image processing toolkit imagexpresshow to view events
cubemx做stm32 USB开发
ImageMagick - 添加水印
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
Talk about sharing before paying
RECH8.0版本学习 days 12 rh134部分
STlink下载出现st-link usb communication error解决方法
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
2020-11-06: go, let's talk about the scheduler.
Two dimensional code location and alarm system of Expressway
插件Bilibili新版0.5.5
心理咨询app开发所具备的优点与功能
11. Service update
高速公路二维码定位报警系统
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
How to add modules to nginx image?
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
如何才能快速正确的部署甘特图