Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Tips and Tricks To Improve Code Readability in C#
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Jaime
June 10, 2012
Programming
1.1k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tips and Tricks To Improve Code Readability in C#
Jaime
June 10, 2012
More Decks by Jaime
See All by Jaime
Mastering the Arcane Art of JavaScriptmancy @ DevSum
vintharas
1
1k
From Angular 1 to Angular 2
vintharas
0
2.2k
Mastering The Arcane Art of JavaScriptmancy - Swetugg Edition
vintharas
1
1.6k
Mastering the Arcane Art of JavaScript-mancy
vintharas
0
3.9k
Level-Up Your Code-Fu With Chuck Norris (and ReSharper, VsVim and NCrunch)
vintharas
0
1.5k
The Web Of The Future - Knockout Components
vintharas
1
1.3k
Introduction to RavenDB
vintharas
0
1.5k
The Path to Jedi Text Editing With VIM - Padawan Edition
vintharas
0
1.9k
TypeScript
vintharas
3
430
Other Decks in Programming
See All in Programming
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
170
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
480
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
420
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
400
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
550
Family mrubyの進捗
kishima
1
120
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
150
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
200
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
490
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
130
速習iPhone Duo対応
yuukiw00w
1
510
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
Scaling GitHub
holman
464
140k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
460
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
240
The SEO Collaboration Effect
kristinabergwall1
1
570
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
330
Embracing the Ebb and Flow
colly
88
5.2k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Optimizing for Happiness
mojombo
378
71k
Test your architecture with Archunit
thirion
2
2.4k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1k
Transcript
P2P Code Academy Becoming a C# Warrior-Poet or Tips and
Tricks To Improve Code Readability in C# 4 30th March
C#
Outline • Object Initializers • Named Arguments • Extension Methods
• LINQ
Ye Olde Classic Constructor
Object Initializers vs Constructors
Object Initializers Uses Default Constructor!
Object Initializers. Benefits • Improved Readability • Less boiler-plate code
– Don’t even need a constructor!
DEMO OBJECT INITIALIZERS
Collection Initializers
Named Arguments • Explicitly name method arguments
Named Arguments. Benefits What the heck is true?
Named Arguments. Benefits
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!
Extension Methods. Syntax Special use of keyword this Look like
instance methods!
Extension Methods Add a method to a primitive type Adding
this method to the string class
Extension Methods Add a method to a primitive type Before
After
DEMO EXTENSION METHODS
Extension Methods Add a method to a compiled custom type
LINQ Query language within C# and VB.NET • Very Expressive
• Extensible • Integrated – LINQ to Objects – LINQ to SQL – LINQ to XML – LINQ to Entities
LINQ. Example Filtering a collection (People older than 30)
LINQ. Example Query Syntax Method Chain Syntax
DEMO LINQ
Summary • Object Initializers • Named Arguments • Extension Methods
• LINQ
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”)); ... }
C#
If you want to know more…
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
Thank you