← 返回
效率工具
中文
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: 无需
#latest
概述
Quick Reference
| Topic | File |
|---|
| ------- | ------ |
| Null reference, nullable types | nulls.md |
| Async/await, deadlocks | async.md |
| Deferred execution, closures | linq.md |
| Value vs reference, boxing | types.md |
| Iteration, equality | collections.md |
| IDisposable, using, finalizers | dispose.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 lossreadonly struct prevents defensive copies — use for performancesealed prevents inheritance — enables devirtualization optimization
版本历史
共 1 个版本
-
v1.0.1
当前
2026-03-29 00:00 安全 安全
安全检测
腾讯云安全 (Sanbu)
安全,无风险
查看报告
🔗 相关推荐
productivity
ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438
📥 147,269
productivity
ide-rea
使用百度AI搜索引擎(BDSE)进行网络搜索。适用于获取实时信息、文档资料或研究课题。
★ 237
📥 105,357
ai-intelligence
ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,351
📥 317,807