当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Utility class functions (continuous update)
- Mate 40系列发布 搭载华为运动健康服务带来健康数字生活
- Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
- WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
- A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
- 2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
- And how to solve the conflict between pop-up menu and pop-up menu
- ImageMagick - 添加水印
- REM: the solution of PC and mobile
- 测试攻城狮必备技能点!一文带你解读DevOps下的测试技术
猜你喜欢

Python3 operating gitlab

【笔记】Error while loading PyV8 binary: exit code 1解决方法

“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮

你真的会使用搜索引擎吗?

Empty test suite appears in JUnit test

cubemx做stm32 USB开发

11. Service update

谈了多年的数字化转型,为什么还有很多企业依然“口头管理”

Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
![[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform](/img/3b/00bc81122d330c9d59909994e61027.jpg)
[graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
随机推荐
Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
How to add modules to nginx image?
Benefits and functions of auto maintenance app development
FreeSWITCH视频会议“标准”解决方案
August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
8. Swarm creates maintenance and horizontal extension service
Nonvolatile MRAM memory used in all levels of cache
Mobile pixel adaptation scheme
gitlab 持续集成开发环境之CI/CD
Design of NAND flash interface control
Git SSH bad permissions
大佬们如何在nginx镜像里面增加模块?
k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
嘉宾介绍|2020 PostgreSQL亚洲大会中文分论坛:潘娟
STlink下载出现st-link usb communication error解决方法
垃圾分类知识竞赛
汽车维修app开发的好处与功能
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
Idea activation to 2089 failure