当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
- 甘特图对活动进行分组教程
- 20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
- yum [Errno 256] No more mirrors to try 解决方法
- Shanghai Pudong Development Bank, which frequently receives penalty tickets, has been cheated by hundreds of millions of yuan in loans, and lacks of internal control?
- 关于DevOps的七大误解,99%的人都曾中过招!
- Developing STM32 USB with cubemx
- HMS Core推送服务,助力电商App开展精细化运营
- 如何使用甘特图图层和筛选器
- 2020-11-06:go中,谈一下调度器。
猜你喜欢

RECH8.0版本学习 days 12 rh134部分

How to add modules to nginx image?

快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!

Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found

图像处理工具包ImagXpress使用教程,如何查看事件

PHP backdoor hiding skills

How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?

FreeSWITCH视频会议“标准”解决方案

win7如何快速打cmd并到达所要的目录

Idea activation to 2089 failure
随机推荐
Two dimensional code location and alarm system of Expressway
图像处理工具包ImagXpress使用教程,如何查看事件
VARCHART XGantt入门教程
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
大佬们如何在nginx镜像里面增加模块?
OpenCV計算機視覺學習(10)——影象變換(傅立葉變換,高通濾波,低通濾波)
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
Insomnia all night
JVM class loading mechanism
List to map (split the list according to the key, and the value of the same key is a list)
The method of local search port number occupation in Windows system
Logo design company, Nanjing
Git SSH bad permissions
Mobile pixel adaptation scheme
Jenkins入门(二)声明式流水线Jenkins Pipeline
2020-11-06: go, let's talk about the scheduler.
Experiment one
2020-08-19: what mechanism does TCP ensure reliability?
Do you really know how to use search engines?
How to solve the problem of blank page in Google Chrome browser