跳至主要内容
小龙虾小龙虾AI
🤖

C#

Avoid common C# mistakes — null traps, async pitfalls, LINQ gotchas, and disposal leaks.

下载681
星标2
版本1.0.1
开发工具
安全通过
💬Prompt

技能说明


name: C# slug: csharp version: 1.0.1 description: Write robust C# avoiding null traps, async deadlocks, and LINQ pitfalls. metadata: {"clawdbot":{"emoji":"💜","requires":{"bins":["dotnet"]},"os":["linux","darwin","win32"]}}

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

如何使用「C#」?

  1. 打开小龙虾AI(Web 或 iOS App)
  2. 点击上方「立即使用」按钮,或在对话框中输入任务描述
  3. 小龙虾AI 会自动匹配并调用「C#」技能完成任务
  4. 结果即时呈现,支持继续对话优化

相关技能