当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- August 18, 2020: introduce Mr process?
- Reserved battery interface, built-in charge and discharge circuit and electricity meter, quickly help easily handle hand-held applications
- 条形码识别器Dynamsoft Barcode Reader v7.5全新上线!
- 你真的会使用搜索引擎吗?
- 南京标识标牌设计制作,导视VI系统设计
- Dynamsoft barcode reader v7.5!
- 小程序商城系统插件代码该如何写?怎么用代码检查添加插件是否成功?
- Characteristics of magnetic memory chip STT-MRAM
- 9. Routingmesh service communication between clusters
- Stm32f030k6t6 compatible replacement smart mm32f031k6t6
猜你喜欢

Insomnia all night

Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops

Empty test suite appears in JUnit test

A good thing for working people -- to temper the will of iron and steel requires such an efficient computer

一种超参数优化技术-Hyperopt

2020-08-15: under what circumstances should data tasks be optimized?

插件Bilibili新版0.5.5

ImageMagick - add watermark
![[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

Stm32f030f4p6 compatible with smart micro mm32f031f4p6
随机推荐
pc端与移动端适配解决方案之rem
南京标识标牌设计制作,导视VI系统设计
频收罚单的浦发银行:增收不增利,曾遭骗贷数亿元,内控缺位?
【原創】ARM平臺記憶體和cache對xenomai實時性的影響
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
你真的会使用搜索引擎吗?
2020-08-19: what mechanism does TCP ensure reliability?
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
一种超参数优化技术-Hyperopt
Solution to st link USB communication error in stlink Download
Three steps to understand Kerberos Protocol easily
A kind of super parameter optimization technology hyperopt
Google browser realizes video playback acceleration function
C# 枚举权限 |和||,&和&&的区别
2020-08-17: how to solve data skew in detail?
confd
2020-08-15: under what circumstances should data tasks be optimized?
三步轻松理解Kerberos协议
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
September 3, 2020: naked writing algorithm: loop matrix traversal.