Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tips and Tricks To Improve Code Readability in C#

Jaime
June 10, 2012

Tips and Tricks To Improve Code Readability in C#

Jaime

June 10, 2012
Tweet

More Decks by Jaime

Other Decks in Programming

Transcript

  1. P2P Code Academy Becoming a C# Warrior-Poet or Tips and

    Tricks To Improve Code Readability in C# 4 30th March
  2. C#

  3. Extension Methods Add methods to existing types: • No need

    to create derived type • No need to re-compile existing type • No need to modify original type • Just static methods in disguise!
  4. LINQ Query language within C# and VB.NET • Very Expressive

    • Extensible • Integrated – LINQ to Objects – LINQ to SQL – LINQ to XML – LINQ to Entities
  5. If you put it all together... Sonnet 138. The Passionate

    Pilgrim C# version while (myLove.Swears(that: ”She is made of truth”)) { do I.Believe(her); while (she.Lies()) she.Might(s => s.Think(I == ”some untutored youth”)); she.Might(s => s.Think(I == ”unskillful”)); ... }
  6. C#

  7. References • Object and Collection Initializers http://bit.ly/csharp-object-collection-initializer • Named Arguments

    http://bit.ly/csharp-named-arguments • Extension Methods http://bit.ly/csharp-extension-methods • LINQ http://bit.ly/linq-language-integrated-query