当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Python 3 operates the Jenkins module API
- Win7 AppCrash (solution)
- The advantages and functions of psychological counseling app
- 2020-08-15: under what circumstances should data tasks be optimized?
- 如何才能快速正确的部署甘特图
- 微服務 - 如何進行服務限流和熔斷
- Configuration of AP hotspot on xunwei-imx6ull development board
- 嘉宾介绍|2020 PostgreSQL亚洲大会中文分论坛:潘娟
- 南京标志设计,logo设计公司
- 2020-08-20: the difference between go and python?
猜你喜欢
你真的会使用搜索引擎吗?
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
The use of Xunwei imx6 development board device tree kernel menuconfig
gitlab 持续集成开发环境之CI/CD
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
PHP后门隐藏技巧
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
How to write plug-in code of small program mall system? How to use code to check whether the plug-in is successfully added?
HMS Core推送服务,助力电商App开展精细化运营
随机推荐
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
如何创建交互式内核密度图表
Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
Gantt chart grouping activities tutorial
OpenCV計算機視覺學習(10)——影象變換(傅立葉變換,高通濾波,低通濾波)
In 2020, how can wechat seal numbers be quickly lifted?
Empty test suite appears in JUnit test
git 提交规范
2020-08-17: how to solve data skew in detail?
RECH8.0版本学习 days 12 rh134部分
嘉宾专访|2020 PostgreSQL亚洲大会中文分论坛:岳彩波
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
New features of vue3
idea 激活到 2089 失效
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
C語言重點——指標篇(一文讓你完全搞懂指標)| 從記憶體理解指標 | 指標完全解析
How does varhart xgantt represent working days on a calendar
FreeSWITCH视频会议“标准”解决方案
Composition of MRAM cache