c# - C# 中的 null 速记?

标签 c# null

有没有办法让这条线更短?

bool pass = d != null && d["k"] != null && (bool)d["k"];

注意:“k”实际上是“一个更长的id”;我替换了它以使其在这篇文章中更具可读性。您的许多建议不检查 d 是否为 null。

最佳答案

它已经勉强可读了,为什么还要缩短它呢?

关于c# - C# 中的 null 速记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1086932/

相关文章:

c# - VS2008 C# : most optimum way to remove multiple occurrences

Flutter/Dart - getter 'path' 被调用为 null。接收器: null Tried calling: path

c# - Entity Framework 4.1 和数据库 (MySQL) 性能问题 {当表包含 320 000 行时如何加快查询以返回第一条记录}

c# - 将 IOrderedEnumerable 转换为 ICollection

c# - Xamarin UWP 似乎绑定(bind)到错误的 View 模型

c# - 为什么 BeginInvoke 不返回 AsyncResult 类型的引用?

ios - Relaese、Alloc 和 Nil 一个对象?

c++ - 在函数中分配后的空指针

c# - 如何在 C# 中以优雅的方式测试对象是否为 null?

vb.net - VB.NET 中的 'foo = Nothing' 和 'foo is Nothing' 有什么区别?