← 返回
效率工具 中文

C#

Avoid common C# mistakes — null traps, async pitfalls, LINQ gotchas, and disposal leaks.
"避开 C# 常见错误——空陷阱、异步陷阱、LINQ 陷阱及资源泄漏。"
ivangdavila
效率工具 clawhub v1.0.1 1 版本 99678.1 Key: 无需
★ 4
Stars
📥 1,778
下载
💾 229
安装
1
版本
#latest

概述

Quick Reference

TopicFile
-------------
Null reference, nullable typesnulls.md
Async/await, deadlocksasync.md
Deferred execution, closureslinq.md
Value vs reference, boxingtypes.md
Iteration, equalitycollections.md
IDisposable, using, finalizersdispose.md

Critical Rules

  • ?. and ?? prevent NRE but ! overrides warnings — still crashes if null
  • .Result or .Wait() on UI thread — deadlock, use await or ConfigureAwait(false)
  • LINQ is lazy — query.Where(...) doesn't execute until iteration
  • Multiple enumeration of IEnumerable — may re-query database, call .ToList() first
  • Closure captures variable, not value — loop variable in lambda captures last value
  • Struct in async method — copied, modifications lost after await
  • String comparison culture — StringComparison.Ordinal for code, CurrentCulture for UI
  • GetHashCode() must be stable — mutable fields break dictionary lookup
  • Modifying collection while iterating — throws, use .ToList() to iterate copy
  • decimal for money — float/double have precision loss
  • readonly struct prevents defensive copies — use for performance
  • sealed prevents inheritance — enables devirtualization optimization

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-29 00:00 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,251
productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 445 📥 226,132
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,351 📥 317,793