寫出有效率的C#程式,依主題條列化的筆記式寫法,光看目錄就馬上吸收到許多 tips,比如第一章〈C# Language idioms〉指出:
Item 1: Prefer Implicitly Typed Local VariablesItem 2: Prefer readonly to const Item 3: Prefer the is or as Operators to CastsItem 4: Replace string.Format() with Interpolated StringsItem 5: Prefer Formattable String for Culture-Specific StringsItem 6: Avoid Stringly-Typed APIsItem 7: Express Callbacks with DelegatesItem 8: Use the Null Conditional Operator for Event InvocationsItem 9: Minimize Boxing and UnboxingItem 10: Use the new Modifier Only to React to Base Class Updates.NET 臉笑維 已經讀了,而且寫下中文心得,請參考。
「效率/Effective」是什麼?書裡提到 :
a slower, correct program is better than a faster, broken program
慢但正確比快但殘破的程式好。所以這本書的重點不在寫出跑得快的程式,而在寫出「正確」的程式,做對了,就做好了。
作者深入 C# Compiler 行為,當我們知道程式怎麼被編譯,便自然能理解如何寫出正確、快速的程式。