TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C# 9 Pattern Matching

64 点作者 benaadams大约 4 年前

7 条评论

infogulch大约 4 年前
I&#x27;m looking forward to Discriminated Unions being finalized. One day... <a href="https:&#x2F;&#x2F;github.com&#x2F;dotnet&#x2F;csharplang&#x2F;issues&#x2F;113" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dotnet&#x2F;csharplang&#x2F;issues&#x2F;113</a>
评论 #26730125 未加载
bob1029大约 4 年前
Pattern matching + switch expressions can make for really concise and functional state machines which can be validated for coverage at compile time.
评论 #26734106 未加载
spaetzleesser大约 4 年前
I love these new additions because I like new stuff but I&#x27;ll admit it&#x27;s hard to keep up and use things with good taste. C# is becoming a BIG language similar to C++. But I guess that&#x27;s the only way to get a broad user base long term.
评论 #26728794 未加载
评论 #26728516 未加载
评论 #26728393 未加载
评论 #26728959 未加载
belinder大约 4 年前
&gt; An interesting case is the is not null pattern. This will check whether the reference is not null. Using != null may check something different when the type overloads the != operator.<p>If it doesn&#x27;t use the != operator then what does it use? How does it work with Nullable&lt;T&gt; which relies on that
评论 #26730344 未加载
评论 #26730085 未加载
rohittidke大约 4 年前
i have been using C# since 2010.I find it a good language but I believe the future is not for strict statically typed languages and but for smart linters which probably could take over compilers.<p>The effort you put into strict types doesn&#x27;t deliver the returns. Languages like Typescript incmy opinion are the best as they provide optional typing and support things mixins for example which is difficult to implement in C#
The_rationalist大约 4 年前
if (person is not null)<p>I really like it, it is more instantaneously readable than the usual != as it is more literate.
评论 #26728386 未加载
评论 #26728500 未加载
评论 #26729032 未加载
评论 #26728452 未加载
Igelau大约 4 年前
C# has some wonderful quality of life improvements over, say, Java. I had to learn it in a rush for a job and really loved the language.<p>Unfortunately, it was the worst job ever. Abusive, corrupt environment. I found a subtle accounting glitch that no one else seemed to quite understand. Assuming good faith, I showed mathematical proof for it, and I was canned shortly thereafter. On its own, the glitch wasn&#x27;t too serious, but I suspect people were nervous that I was digging too close to something else.<p>Never bothered to set up the env at home again after that on account of the foul taste in my mouth, but that was hardly C#&#x27;s fault. Just found other things to do.
评论 #26729382 未加载