C# 3.5 – Properties Shorthand

I must tell you if today your C# knowledge is not up to date then you might face tough time with future versions of the language. Microsoft developers will keep on adding new things ranging from entirely new features like LINQ to something like Implicit types or Object initializations. Last two features that I’ve mentioned are due to LINQ and secondly they provide some kind of syntactical sugar for developers. In future, VB.NET and C# will take entirely different paths. C# will become more performance oriented and VB.NET more developer friendly. VB.NET will target UI where as C# will mostly be used as class libraries. I am not sure when will this happen but it will happen soon [trust my Microsoft contacts 🙂 ]

Let me show you how property shorthand feature of C# works from inside. We will start of with a simple console application and add code as needed.

Adding property shorthand to your code
Type prop in code window and let intellisense jump in. Then select “prop” and press Tab 2 times. A property shorthand will appear

Complete your class definition
Add 3 shorthand properties and one normal property. Your final class definition will look like this

Create a class that will use Customer object.
Main() method in Program.cs would be enough for us

And the output is as expected,

Let us examine the IL that is generated for this managed assembly. Below are two images one with IL showing members of Customer class and next one with one method expanded.

For the properties that we created with shorthand, C# compiler added a backing field for each shorthand property in this format,
k_BackingField: private TypeOfShrtHandProperty

get_FirstName method expanded
Image shown below looks at the IL generated for get_FirstName method. Second IL instruction ‘ldflf’ i.e. Load Field, works with backing field created by the compiler. set_FirstName() also uses this backing field.

Don’t expect that these shorthands will support validations etc. These are simple properties and just adds thread safety over using class variables directly. If we don’t want any thread safely and no validations, then we should not provide properties. I guess this is a cool new feature but unless you understand how it works inside you will not able to fully utilize it.

Next I’ll add a small post related to introduction of partial methods in C#. I am down with Viral from last few days but today I am feeling quite well. I hope! to get well soon.

~ILdasm rOcKs~



  1. [B]NZBsRus.com[/B]
    Escape Slow Downloads With NZB Files You Can Instantly Find High Quality Movies, Console Games, MP3 Albums, Applications and Download Them @ Electric Rates



  2. [B]NZBsRus.com[/B]
    Dismiss Slow Downloads With NZB Files You Can Hastily Search HD Movies, Games, MP3s, Software and Download Them at Flying Speeds

    [URL=http://www.nzbsrus.com][B]Newsgroup Search[/B][/URL]


  3. Aid to pass the rude with two backs casinos? examine this immature [url=http://www.realcazinoz.com]casino[/url] guide and steppe online casino games like slots, blackjack, roulette, baccarat and more at http://www.realcazinoz.com .
    you can also probe our belated [url=http://freecasinogames2010.webs.com]casino[/url] mastery at http://freecasinogames2010.webs.com and prostrate bona fide tangled bread !
    another friendless [url=http://www.ttittancasino.com]casino spiele[/url] purlieus is http://www.ttittancasino.com , because german gamblers, protect not rococo online casino bonus.


  4. Validate Our Crestfallen Prices at http://www.Pharmashack.com, The Famed [b][url=http://www.pharmashack.com]Online Dispensary [/url][/b] To [url=http://www.pharmashack.com]Buy Viagra[/url] Online ! You Can also Gather up Great Deals When You [url=http://www.pharmashack.com/en/item/cialis.html]Buy Cialis[/url] and When You You [url=http://www.pharmashack.com/en/item/levitra.html]Buy Levitra[/url] Online. We Also Be subjected to a Vital Generic [url=http://www.pharmashack.com/en/item/phentermine.html]Phentermine[/url] In stick of Your Meat ! We Yield up Swap identification [url=http://www.pharmashack.com/en/item/viagra.html]Viagra[/url] and Also [url=http://www.pharmashack.com/en/item/generic_viagra.html]Generic Viagra[/url] !


  5. Someone deleted several links from quickshare and zshare …

    From now, we will use http://www.tinyurlalternative.com as our main [url=http://www.tinyurlalternative.com]url shortener[/url], so every link will be there and visible for everyone.

    You can choose from many great [url=http://kfc.ms]short url[/url] address like:

    kfc.ms easysharelink.info jumpme.info megauploadlink.info megavideolink.info mygamelink.info myrapidsharelink.info mytorrentlink.info myurlshortener.com mywarezlink.info urlredirect.info urlshrinker.info weblinkshortener.com youtubelink.info and many others.

    They have over 60 other available domains and the [url=http://myurlshortener.com]url shortener[/url] service work properly for free without any registration needed.

    So we think it is good notion and propose you to use [url=http://urlredirect.info]url redirect[/url] service too!

    Thank you.


  6. [b]Website Traffic[/b]

    A new way to get traffic to your website. Not only will you get loads of [url=http://www.fastpixeltraffic.com/]traffic[/url] more and more everyday you will also get backlinks with all the other sites on the [url=http://www.fastpixeltraffic.com/]grid[/url] getting you a better search engine ranking which will get you even more [url=http://www.fastpixeltraffic.com/]website traffic[/url].Get on the pixel grid today and let the traffic come to you.Taking the internet by storm.The new way to advertise.

    Visit: http://www.fastpixeltraffic.com/


  7. Your blog is outrageous! I mean, Ive never been so entertained by anything in my life! Your vids are perfect for this. I mean, how did you manage to find something that matches your style of writing so well? Im really happy I started reading this today. Youve got a follower in me for sure!


  8. top [url=http://www.001casino.com/]casino bonus[/url] brake the latest [url=http://www.realcazinoz.com/]casino games[/url] autonomous no deposit bonus at the chief [url=http://www.baywatchcasino.com/]unshackle casino games


  9. top [url=http://www.001casino.com/]casino online[/url] brake the latest [url=http://www.casinolasvegass.com/]online casino[/url] manumitted no deposit bonus at the leading [url=http://www.baywatchcasino.com/]spare casino games


  10. paradox software http://buyoem.co.uk/category-100-102/Business?page=7 sunguard software [url=http://buyoem.co.uk/product-35372/3herosoft-iPod-to-Computer-Transfer-3-8-MacOSX]optipix software downloads[/url] paper doll software
    [url=http://buyoem.co.uk/es/category-100-111/Herramientas-de-sistema]Herramientas de sistema – Software Store[/url] gps software nz


  11. Hello. Facebook takes a [url=http://www.casinogames.gd]no deposit casino bonus[/url] stick on 888 casino mete out: Facebook is expanding its efforts to push aside rash real-money gaming to millions of British users after announcing a give out with the online gambling found search for 888 Holdings.And Bye.


  12. system booster software http://buysoftwareonline.co.uk/product-10235/SpotAuditor-3-6-6 act software consulting detroit [url=http://buysoftwareonline.co.uk/product-16560/Folder-icon-Maker-X-Mac]template word 2003 install software[/url] mdsolids 3.2 software free
    [url=http://buysoftwareonline.co.uk/category-100-106/Server-Software?page=3]Server Software – Software Store[/url] best photo editing software available


  13. sxs software http://buysoftwareonline.co.uk/category-7/Programming-and-Development symantec hp suretape backup software [url=http://buysoftwareonline.co.uk/it/product-37131/RAC-Server-3-3]math software linux download[/url] serif photoplus editing software
    [url=http://buysoftwareonline.co.uk/product-36586/Microsoft-Windows-7-Ultimate-x32-Spanish]Microsoft Windows 7 Ultimate x32 Spanish – Software Store[/url] windows media player software


  14. [url=http://englandpharmacy.co.uk/products/zestril.htm][img]http://onlinemedistore.com/6.jpg[/img][/url]
    fuquay varina n c kroger pharmacy http://englandpharmacy.co.uk/products/plendil.htm matt connell pharmacy director [url=http://englandpharmacy.co.uk/categories/cholesterol.htm]cvs pharmacy wakefield ma phone[/url]
    mississippi board of pharmacy http://englandpharmacy.co.uk/products/torsemide.htm pharmacy ohio [url=http://englandpharmacy.co.uk/products/kamasutra-longlast-condoms.htm]kamasutra longlast condoms[/url]
    how much does a pharmacy tech earn http://englandpharmacy.co.uk/products/erectalis.htm online pharmacy degree [url=http://englandpharmacy.co.uk/products/endep.htm]long term care pharmacy providers[/url]
    purchase altace online rolipram pharmacy http://englandpharmacy.co.uk/products/emsam.htm belmont pharmacy school and condo and nashville [url=http://englandpharmacy.co.uk/products/ventolin.htm]ventolin[/url]


  15. free dating site romanians [url=http://freeinternetdating.info/friendship/friendship-valentines-gifs-and-cartoons]friendship valentines gifs and cartoons[/url] dating old piano
    transexual dating new jersey http://freeinternetdating.info/love/summary-ofto-sir-with-love canadian pinoy dating
    talking dating relationship [url=http://freeinternetdating.info/bride/russain-bride-visa-requirement-to-usa]best dating template sites[/url] biltmore pocketwatch dating


  16. An outstanding share! I've just forwarded this onto a co-worker who was conducting a little research on this. And he in fact ordered me breakfast because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending the time to discuss this matter here on your web page.

    Feel free to surf to my weblog – traffic exchange


  17. you're really a excellent webmaster. The site loading velocity is amazing. It seems that you are doing any unique trick. In addition, The contents are masterwork. you have done a wonderful job in this matter!

    Feel free to surf to my web site: web traffic exchange


  18. membership lists for dating sites http://loveepicentre.com/success_stories/ black american dating asian americans
    dating prison women [url=http://loveepicentre.com/contact/]ghana dating dites[/url] britney spears dating paparazzi
    dating tauranga [url=http://loveepicentre.com/]romanian men dating[/url] free dating site in american [url=http://loveepicentre.com/user/rahulkrishnarbk/]rahulkrishnarbk[/url] bolivian dating sites


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s