惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - ProjectDD

NET 中 Async/Await 的演进:从状态机到运行时优化的 Continuation C# 指针用法小结 C# BinaryPrimitives 类 C# 内存对齐 linq 查询关于 from子句 关于C# await的一点新理解 关于排序算法 C# Dev Kit 经常导致崩溃 不太会用Span<T> 看文档上的优点估摸着试试 span,memory,ArrayPool,MemoryPool,等的性能对比 C# simd 性能雷点记录 高中生理解梯度为何是方向导数极大值 概略 deep net 通过relu 进行函数逼近 win10 下安装 rust 的 依赖配置,通过vs2022 C# 有多需要aot 24个希腊字母的中文拼音版 英语发音探讨 sagemath 9.x 下的 jupyter 工作路径设置 Serializing delegates is not supported on this platform
C# 模式匹配里应该注意的几点
ProjectDD · 2022-10-09 · via 博客园 - ProjectDD

马上就要出C#11了,近几个版本模式匹配一直在更新,参见官网:模式 - C# 参考 | Microsoft Learn

使用模式主要就是switch, 分两种 switch 语句和表达式, 

语句:(功能全面)

switch(i){

case const_exp1: /*customer logic*/ break;

case const_exp2: /*customer logic*/ break;

//...

default /*customer logic*/ break;

}

表达式:(需要有返回值)

x=i switch{

const_exp1=>/*customer expression*/,

const_exp2=>/*customer expression*/,

//...

_=>/*customer expression*/,

};

需要特别指出值得注意的是

1,常量声明式就是等于的意思 

2,关系模式(>,>=,<,<=): 由关系运算左置来表达,注意此关系模式中不包括==,!= , ==这个直接属于声明模式,!= 则属于 not 逻辑模式之列

3,模式匹配,依赖于常量表达式,否则需要启用写法比较冗余 难看的 when子句,when子句相当于一个一般逻辑表达式,范围全面但写法冗余最好别用