<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7307193957300897778</id><updated>2011-04-21T21:52:54.572-07:00</updated><category term='asp.net performance'/><category term='SEO'/><title type='text'>.NET Spider</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-7947404736586133824</id><published>2009-03-20T02:39:00.001-07:00</published><updated>2009-03-20T02:39:03.632-07:00</updated><title type='text'>10 C# Shorthands that improve productivity</title><content type='html'>&lt;p&gt;&lt;i&gt;One of the best things about C# is that as the language and libraries expand thought is put into keeping things readable. Below I have listed 10 shorthands that you can use to make your code tighter and less wordy. No doubt you know one or more already — but do you currently use all ten of them ?&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dijksterhuis.org/10-c-coding-shorthands-that-improve-productivity/"&gt;Visit here ..&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-7947404736586133824?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/7947404736586133824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=7947404736586133824&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/7947404736586133824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/7947404736586133824'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/03/10-c-shorthands-that-improve.html' title='10 C# Shorthands that improve productivity'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-2053667155470128308</id><published>2009-03-10T21:03:00.000-07:00</published><updated>2009-03-10T21:06:44.242-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SEO'/><title type='text'>SEO optimization</title><content type='html'>&lt;span style="font-size:100%;"&gt;If &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:verdana;"&gt;you are building a new ASP.NET application, &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(204, 103, 20) ! important; font-weight: 400; position: static; font-style: italic;font-family:Lucida Grande,Tahoma,Arial,Helvetica,sans-serif;font-size:100%;"  &gt;&lt;span class="kLink" style="border-bottom: 1px solid rgb(204, 103, 20); color: rgb(204, 103, 20) ! important; font-weight: 400; position: static;"&gt;SEO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;has become a big factor in how you plan the structure / code of the site.  But quite an important part of the site which are often overlooked are the URL’s, and a lot of people do the basics which I’ll show below but there are a few common things people tend to miss or never thought could be a problem. I use ISAPI rewrite for most of my sites, which is an amazingly effective tool for sorting duplicate content and &lt;span style="font-style: italic;"&gt;SEO &lt;/span&gt;issues which I’ll show below&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;h2&gt;&lt;a class="postheader taggedlink" href="http://www.blogfodder.co.uk/post/2009/03/6-SEO-Tips-For-ASPNET-URLrsquo3bs.aspx"&gt;6 SEO Tips For ASP.NET URL’s&lt;/a&gt;&lt;/h2&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-2053667155470128308?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/2053667155470128308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=2053667155470128308&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/2053667155470128308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/2053667155470128308'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/03/if-you-are-building-new-asp.html' title='SEO optimization'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-7009624595809293630</id><published>2009-02-24T06:33:00.000-08:00</published><updated>2009-02-24T06:38:11.888-08:00</updated><title type='text'>Posting data to a REST service using C#</title><content type='html'>&lt;p&gt;As Rest services are becoming more and more common the need is arising to be able to post data to them via .net.  Now normally when you want to post data to a web resource you normally would do so using a web service.  And when you use a web service all the ‘plumbing’ is taking care of for you by the .Net framework.  However since we are not posting to a web service there is a bit of code you need to create in order to post to a REST service.  The good news is that the amount of code you need to create is not all the bad.&lt;/p&gt;  &lt;p&gt;Lets pretend we want to post data to the following REST service &lt;a title="http://localhost:2844/Home/PostDataTester" href="http://localhost:2844/Home/PostDataTester"&gt;http://localhost:2844/Home/PostDataTester&lt;/a&gt; which takes in 3 values&lt;/p&gt;&lt;p&gt;  &lt;/p&gt;&lt;ol&gt;&lt;li&gt;someValue which is a string &lt;/li&gt;&lt;li&gt;anotherValue which is a string &lt;/li&gt;&lt;li&gt;finalValue which is an Int32 &lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;Now that we know what the REST service contract looks like we should take a look at the code needed to actually connect to and post the data.&lt;/p&gt;  &lt;p&gt;First we are going to look at the main logic which will post the data, however, this method has 2 helper methods which we also need to discuss.&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;public void SendMessage( string endPoint, Dictionary&lt;&gt; paramters)  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;{  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     var populatedEndPoint = CreateFormattedPostRequest( paramters );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     byte[] bytes = Encoding.UTF8.GetBytes( populatedEndPoint );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     HttpWebRequest request = CreateWebRequest( endPoint, bytes.Length );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     using ( var requestStream = request.GetRequestStream() )  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;         requestStream.Write( bytes, 0, bytes.Length );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     }  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     using ( var response = (HttpWebResponse)request.GetResponse() )  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;         if ( response.StatusCode != HttpStatusCode.OK )  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;         {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;             string message = String.Format( "POST failed. Received HTTP {0}", response.StatusCode );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;             throw new ApplicationException( message );  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;         }  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     }  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;}  &lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;As you can see from above, the code needed to actually post the data is not too bad, in fact it is fairly simple.  Now that we have seen the main logic lets take a look at the various helpers methods.&lt;/p&gt;  &lt;p&gt;The first helper method is the method which will actually create the &lt;span style="color:#0080ff;"&gt;HttpWebRequest&lt;/span&gt; object for us&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;private HttpWebRequest CreateWebRequest( string endPoint, Int32 contentLength )&lt;br /&gt;{&lt;br /&gt;    var request = (HttpWebRequest)WebRequest.Create( endPoint );&lt;br /&gt;&lt;br /&gt;    request.Method = "POST";&lt;br /&gt;    request.ContentLength = contentLength;&lt;br /&gt;    request.ContentType = "application/x-www-form-urlencoded";&lt;br /&gt;&lt;br /&gt;    return request;&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;Pay close attention to 2 things here&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;The method on the request must be POST &lt;/li&gt;&lt;li&gt;The content type on the request must be application/x-www-form-urlencoded &lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;The second helper method will take in a list of values which need to be posted and create the value query string for posting&lt;/p&gt;&lt;p style="color: rgb(153, 0, 0);"&gt;private string CreateFormattedPostRequest( ICollection&gt; values )&lt;br /&gt;{&lt;br /&gt;    var paramterBuilder = new StringBuilder();&lt;br /&gt;    var counter = 0;&lt;br /&gt;    foreach ( var value in values )&lt;br /&gt;    {&lt;br /&gt;        paramterBuilder.AppendFormat( "{0}={1}", value.Key, HttpUtility.UrlEncode( value.Value ) );&lt;br /&gt;&lt;br /&gt;        if ( counter != values.Count - 1 )&lt;br /&gt;        {&lt;br /&gt;            paramterBuilder.Append( "&amp;amp;" );&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        counter++;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    return paramterBuilder.ToString();&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;Pay close attention to the fact that we are doing UrlEnoding on our values which we are pushing to the service, this is very, very important.&lt;/p&gt;  &lt;p&gt;As you can see, the actual code to post a message to a REST service is simple and trivial and can be implemented with very little effort.&lt;/p&gt;&lt;p&gt;Source: http://devlicio.us&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span&gt;&lt;span class="keyword"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-7009624595809293630?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/7009624595809293630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=7009624595809293630&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/7009624595809293630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/7009624595809293630'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/02/posting-data-to-rest-service-using-c.html' title='Posting data to a REST service using C#'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-2382546788633903985</id><published>2009-01-21T05:19:00.000-08:00</published><updated>2009-01-21T05:22:17.512-08:00</updated><title type='text'>Why get bored, when you could be coding</title><content type='html'>&lt;p style="font-family: verdana;"&gt; &lt;span style="font-size:100%;"&gt;Hi Guys,&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;"&gt;&lt;span style="font-size:100%;"&gt;I found this article on &lt;span class="entry-source-title-parent"&gt;&lt;a href="http://www.google.co.in/reader/view/feed/http%3A%2F%2Ffeeds.feedburner.com%2Fspoiledtechie" class="entry-source-title" target="_blank"&gt;Spoiled Techie&lt;/a&gt; site. But it looks like this speaks about my mind.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;"&gt;&lt;span style="font-size:100%;"&gt;There are many times in life when you have nothing to do.  As a member of the civilized world, we as a people are becoming bored every day. We are a world that watches more movies everyday.  I bet if the movie industry came out, we would see the statistics of movie goers have increased over the last 20 years.  We are a world that technology has allowed to do many things that have taken us hours or even days to do before.  &lt;strong&gt;Our world is speeding up and everyone wants more.  &lt;/strong&gt;They want to get done faster, finish things better and move on to the next project.  People get bored easily these days because production levels have gone through the roof with the help of technology which allows us to become lazier.  Life in it self is full of its bored moments.  People in general have less and less to do because technology has sped up our daily tasks.  I think that is one reason why more and more movies are being watched.  People want more out of life and movies give you that little action and adventure that your looking for. Movies give you the ability to stop boredom.  To some people, movies are a way of life.  &lt;/span&gt; &lt;/p&gt; &lt;p style="font-family: verdana;"&gt; &lt;span style="font-size:100%;"&gt;My life is no different, technology has made my life so much easier than people that have come before me.  My solution of boredom?  &lt;strong&gt;People need to find a hobby.&lt;/strong&gt;  They need to find something that will keep their attention.  If they don't they will inevitably become a YouTuber.&lt;/span&gt; &lt;/p&gt; &lt;blockquote style="font-family: verdana;"&gt;  &lt;p&gt;  &lt;span style="font-size:100%;"&gt;&lt;strong&gt;YouTuber&lt;/strong&gt; -A person that watches excessive amounts of YouTube to pass the time.  Not only applied to YouTube, but a person that does an excessive amount of anything to which they do just to pass the time.  This isn't a hobby, but a time waster.   &lt;/span&gt;  &lt;/p&gt; &lt;/blockquote&gt; &lt;p style="font-family: verdana;"&gt; &lt;span style="font-size:100%;"&gt;People that watch and enjoy YouTube to me are either doing it because that is their hobby or they are doing it to pass the time.  I personally code as my hobby or down time.  I not only do it as a hobby, but to make my life and everyone else's life a bit easier and a bit better.  I am like every other programmer or hacker the does it. I chip away at making life better.  I don't think I will ever be as rich as Bill Gates, but I hope to have helped as many people in my life as he has.  This is where coding/hacking comes in. When I get bored I code; when I want to do something, I code.  Due to technology, I get to do a lot of my hobby.  &lt;/span&gt; &lt;/p&gt; &lt;p style="font-family: verdana;"&gt; &lt;span style="font-size:100%;"&gt;If this is your first time reading, then you wouldn't know that I usually try to have around 2-4 projects going on at once.  My projects are all for making life a bit easier for me and everyone that has access to a computer and internet.  I have about 15 ideas that could be implemented currently and boredom brings my code to life.  Like I said before, I don't get bored, I code.  Right now I am even sitting with friends and watching some football.  I can keep a conversation, watch football and blog all at once.  When I get bored, I code (so I am not coding, but being productive).  &lt;/span&gt; &lt;/p&gt; &lt;p style="font-family: verdana;"&gt; &lt;span style="font-size:100%;"&gt;&lt;strong&gt;The point I was trying to get across:&lt;/strong&gt; Stop being bored, &lt;strong&gt;be productive.  &lt;/strong&gt;Find a hobby, find something.  &lt;strong&gt;Carpe Diem (Seize the day).  &lt;/strong&gt;Learn something, do something and retain it. When I get bored, I code.  Life is not about being bored.  &lt;strong&gt;Life is about doing something.  &lt;/strong&gt;Its about &lt;strong&gt;achieving something better than your self.  &lt;/strong&gt;My something better right now in my &lt;strong&gt;life is coding and my great girlfriend.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Source: &lt;/span&gt;&lt;span class="entry-source-title-parent"&gt;&lt;a href="http://www.google.co.in/reader/view/feed/http%3A%2F%2Ffeeds.feedburner.com%2Fspoiledtechie" class="entry-source-title" target="_blank"&gt;Spoiled Techie&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-2382546788633903985?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/2382546788633903985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=2382546788633903985&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/2382546788633903985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/2382546788633903985'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/why-get-bored-when-you-could-be-coding.html' title='Why get bored, when you could be coding'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-8447977742323343775</id><published>2009-01-20T09:06:00.000-08:00</published><updated>2009-01-20T09:09:19.910-08:00</updated><title type='text'>C# 4.0 Dynamic Lookup</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: verdana;"&gt;One of the core features introduced in C# 4.0 is called &lt;/span&gt;&lt;strong style="font-family: verdana;"&gt;Dynamic Lookup&lt;/strong&gt;&lt;span style="font-family: verdana;"&gt; which allows a unified approach to invoking things dynamically. Currently, when you call object methods or properties, the compiler checks that they exist and raises an error if they do not. With dynamic lookup, you can call any method or property, and they are not checked until runtime. C# 4.0 is extending towards the dynamic languages. Having an object, you do not need to worry about whether it comes from COM, Python, JavaScript or reflection, you just apply operations to it and leave it to the runtime to figure out what exactly those operations mean. &lt;/span&gt;&lt;/span&gt;  &lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;C# 4.0 will support dynamic typing through a new static type called “dynamic”. As already described, when you have an object of type dynamic you can do whatever you like with it, those operations are resolved only at runtime. Lets first see a method declaration:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;public dynamic GetService()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;    // Getting some service...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and how to use it:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;dynamic service = GetService();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;service.Do("YourJob");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The C# compiler allows you to call a method with any name and any arguments because service is declared as dynamic. Scary, isn’t it? Only at runtime will you get an error if the returned object doesn’t have such a method.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;Actually,,,, I don't like it&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;What shall I do with the GetService Method? I don’t know and neither does IntelliSense. If I mistakenly call a non existing method or even had a typo while typing an existing method, I will get a runtime error while I could know about my mistake at compile time. I can’t see one good thing here. The problem is that when running our program, we never reach all of the paths so we might never face our problem, our customer will. If it is up to me, I won’t use this feature, but I am not alone, there are third party libraries and co workers who might use the dynamic keyword and make me helpless. The dynamic keyword is open to abuse as anything could be. This feature moves us away from strong typing meaning that many years of wisdom is being thrown out of the window. What is wrong about interfaces? It gives flexibility but it keeps us from stupid mistakes as well. &lt;/span&gt;&lt;/p&gt; &lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;I heard that &lt;span style="font-weight: bold;"&gt;Hejlsberg &lt;/span&gt;noted that developers should not now declare all variables as dynamic, but should continue to rely on static typing as standard, because this is safer and faster. Do you really trust C# developers so much? It makes me cringe. You can’t provide a heavy tool for everybody, many developers won’t use it correctly and wisely and the other developers will suffer from their stupidity. Why leaving an open door for unnecessary mistakes? Why?&lt;/span&gt;&lt;/p&gt; &lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;There are some more features in C# 4.0 like Named and Optional Arguments, Covariance and Contravariance for generic types. I decided to focus on the dynamic lookup feature because I am really afraid from its consequences and can’t understand what is the benefit of it. Do you agree with me? Don’t you agree and think that I am paranoid? Comment and start a debate.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: verdana;" align="left"&gt;&lt;span style="font-size:85%;"&gt;Source: http://www.dev102.com&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-8447977742323343775?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/8447977742323343775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=8447977742323343775&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/8447977742323343775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/8447977742323343775'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/c-40-dynamic-lookup.html' title='C# 4.0 Dynamic Lookup'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-3029824238465692390</id><published>2009-01-20T07:18:00.001-08:00</published><updated>2009-01-20T07:25:06.098-08:00</updated><title type='text'>ASP.NET Process Identity</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;For additional security, the ASP.NET application worker process (aspnet_wp.exe) runs using an account (ASPNET) with weaker privileges than the Local System account. By doing so, an intruder will not have administrative access if security is breached. This is because the Local System account has access to almost all resources on the local computer not specifically denied to it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;To run the worker process using a specified account, modify the &lt;processmodel&gt; element in the root configuration file (machine.config), located in the \%windows%\Microsoft.NET\Framework\Version\Config folder, as shown below: &lt;/processmodel&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;machine.config file&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;   &amp;lt;processmodel&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;      enable="true" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;      userName="domain\user" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;      password="password"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;   /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-family:verdana;" &gt;&lt;processmodel&gt;&lt;br /&gt;&lt;/processmodel&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;In addition to specifying a particular user account, you can also set the userName attribute to one of two specially recognized values, "SYSTEM" and "MACHINE". In both cases, you should set the password attribute to "AutoGenerate", which instructs Windows to manage the password. The default userName setting is "MACHINE", which is the worker process that uses a local account named ASPNET. This account is similar to the IWAM_machinename account used by Internet Information Services (IIS) for running instances of dllhost.exe when hosting applications built using ASP 3.0 and earlier. If you specify "SYSTEM", the worker process uses the Local System account. The ASPNET account is created during installation of the .NET Framework.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;If you use a custom account, that account must have the following necessary access rights:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;Read/write access is required for:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;            The %installroot%\ASP.NET Temporary Files directory. Subdirectories beneath this root are used for dynamically compiled output.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;The %temp% directory, which is used by the compilers during dynamic compilation.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Read access is required for:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;              The application directory.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;The %installroot% hierarchy to make it possible to access to system assemblies.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;The Web site root directory (e.g., the path at which the "Default Web Site" points, typically %systemdrive%\inetpub\wwwroot).&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;The Global Assembly Cache, %windir%\assembly.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-3029824238465692390?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/3029824238465692390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=3029824238465692390&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/3029824238465692390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/3029824238465692390'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/aspnet-process-identity_20.html' title='ASP.NET Process Identity'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-1092819343374269476</id><published>2009-01-17T10:30:00.000-08:00</published><updated>2009-01-17T10:32:24.874-08:00</updated><title type='text'>C# Trivia - What? No Overflow?</title><content type='html'>&lt;span class="Apple-style-span"   style="color: rgb(51, 51, 51);   line-height: 18px; font-family:Arial;font-size:12px;"&gt;&lt;p&gt;If you've been dealing with C# for a long time, then you have probably at one point or another tried to do this:&lt;/p&gt;&lt;div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; margin-left: 0px !important; padding-top: 1px; "&gt;&lt;div class="bar" style="padding-left: 45px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 8px; padding-left: 10px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); padding-bottom: 10px; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;print&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('About',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(92, 92, 92); "&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt; myNumber = 9999999999;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;And you know that you can't, the compiler tells you that this number if just tooooooooo big! It can't handle that pesky giant number. Why can't it handle it? Well, that is because it is a fixed size, and passing that size will cause an overflow, right? Which is what happens when we do this:&lt;/p&gt;&lt;div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; margin-left: 0px !important; padding-top: 1px; "&gt;&lt;div class="bar" style="padding-left: 45px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 8px; padding-left: 10px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); padding-bottom: 10px; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;print&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('About',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(92, 92, 92); "&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt; myNumber = &lt;/span&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;.MaxValue;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;myNumber += 1;  &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;Right? Right? Nope. Trust me, it won't blow up. Try it, I'll wait. Okay, so you're back, and you are probably surprised that you got this:&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.codethinked.com/image.axd?picture=WindowsLiveWriter/CTriviaWhatNoOverflow_DAAC/image_a2185b9c-747c-4684-b0e8-ba95d156e2a9.png" border="0" alt="image" width="285" height="68" style="background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; vertical-align: bottom; " /&gt;&lt;/p&gt;&lt;p&gt;You may be thinking to yourself, "C# doesn't do overflow checking?" And the answer to your question is "not by default" when you are using non-constant expressions. And the reason is that they wanted to squeeze every last little bit of performance out of C#. It is a good thing that the .net runtime forces array bounds checking, or they might have turned that off as well! As a side note, you can read an interesting story about the F# team trying to get around array bound checking &lt;a href="http://cs.hubfs.net/blogs/f_team/archive/2006/08/15/506.aspx" style="border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; "&gt;in this post&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;So, what do we do if we want to get numeric overflow checking? Well, we have two options. First, we can just put our code inside of a "checked" section:&lt;/p&gt;&lt;div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; margin-left: 0px !important; padding-top: 1px; "&gt;&lt;div class="bar" style="padding-left: 45px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 8px; padding-left: 10px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); padding-bottom: 10px; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;print&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('About',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(92, 92, 92); "&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;checked&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;{  &lt;/span&gt;&lt;/li&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt; myNumber = &lt;/span&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;.MaxValue;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;myNumber += 1;  &lt;/span&gt;&lt;/li&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;}  &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;Most likely you have never even seen this keyword, but it causes integer overflow checking to be turned on inside of this block. You must also keep in mind that "checked" blocks to not affect methods that are called from this block. If we did something like this:&lt;/p&gt;&lt;div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; margin-left: 0px !important; padding-top: 1px; "&gt;&lt;div class="bar" style="padding-left: 45px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 8px; padding-left: 10px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); padding-bottom: 10px; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;print&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('About',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(92, 92, 92); "&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;checked&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;{                  &lt;/span&gt;&lt;/li&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;UncheckedMethod();  &lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;}  &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;The code in the "UncheckedMethod" would not get overflow checking.&lt;/p&gt;&lt;div class="sidenote" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); font-style: italic; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 1em; padding-bottom: 0px; padding-left: 1em; "&gt;&lt;h3 style="border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(250, 192, 138); color: rgb(245, 130, 22); font: normal normal bold 120%/normal 'Trebuchet MS', Verdana, Arial, sans-serif; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-bottom: 2px; text-transform: uppercase; "&gt;SIDENOTE&lt;/h3&gt;&lt;p&gt;The "checked" section is only for integer math. Floats (System.Single) and doubles (System.Double) will never use overflow checking while Decimal (System.Decimal) will always use overflow checking.&lt;/p&gt;&lt;/div&gt;&lt;p&gt;Your other option is to turn on overflow checking for the entire project. This can be done by going to the project properties:&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.codethinked.com/image.axd?picture=WindowsLiveWriter/CTriviaWhatNoOverflow_DAAC/image_edec1ce6-e599-4bc1-a3a8-d2319245c3f0.png" border="0" alt="Project Options" width="258" height="346" style="background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; vertical-align: bottom; " /&gt;&lt;/p&gt;&lt;p&gt;Then to the "Build" tab:&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.codethinked.com/image.axd?picture=WindowsLiveWriter/CTriviaWhatNoOverflow_DAAC/image_534bc9a6-d8ab-471f-81de-a42b6a7fb2c3.png" border="0" alt="Project Options Build Tab" width="193" height="126" style="background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; vertical-align: bottom; " /&gt;&lt;/p&gt;&lt;p&gt;Then in the bottom right corner you will find an "Advanced" button:&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.codethinked.com/image.axd?picture=WindowsLiveWriter/CTriviaWhatNoOverflow_DAAC/image_3d2a13ba-acca-4a81-ab2a-da83186206eb.png" border="0" alt="Project Options Advanced Button" width="167" height="111" style="background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; vertical-align: bottom; " /&gt;&lt;/p&gt;&lt;p&gt;And once you click that a dialog will appear and you can check this button:&lt;/p&gt;&lt;p&gt;&lt;img src="http://www.codethinked.com/image.axd?picture=WindowsLiveWriter/CTriviaWhatNoOverflow_DAAC/image_2ce736f7-3e4c-40ea-a933-b0b521611c44.png" border="0" alt="Overflow Checking" width="444" height="137" style="background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(191, 201, 211); border-right-color: rgb(191, 201, 211); border-bottom-color: rgb(191, 201, 211); border-left-color: rgb(191, 201, 211); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; vertical-align: bottom; " /&gt;&lt;/p&gt;&lt;p&gt;This will have the same effect on the entire project as the "checked" block. It will cause overflow checking on integer math only! But what if we want to have overflow checking on in the project, but we have sections that have overflow checking off? Well, they have created an "unchecked" block for us to use:&lt;/p&gt;&lt;div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 99%; overflow-x: auto; overflow-y: auto; margin-top: 18px !important; margin-right: 0px !important; margin-bottom: 18px !important; margin-left: 0px !important; padding-top: 1px; "&gt;&lt;div class="bar" style="padding-left: 45px; "&gt;&lt;div class="tools" style="padding-top: 3px; padding-right: 8px; padding-left: 10px; font: normal normal normal 9px/normal Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); padding-bottom: 10px; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); "&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;view plain&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;copy to clipboard&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;print&lt;/a&gt;&lt;a href="http://www.codethinked.com/post/2009/01/11/C-Trivia-What-No-Overflow.aspx#" onclick="dp.sh.Toolbar.Command('About',this);return false;" style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; border-top-style: none; border-right-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 9px; background-color: inherit; margin-right: 10px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(127, 174, 214); color: rgb(0, 93, 174); text-decoration: none; background-position: initial initial; "&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol start="1" class="dp-c" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(92, 92, 92); "&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;unchecked&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;{  &lt;/span&gt;&lt;/li&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt; myNumber = &lt;/span&gt;&lt;span class="keyword"  style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 102, 153); font-weight: bold; background- color:inherit;"&gt;int&lt;/span&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;.MaxValue;  &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); color: rgb(92, 92, 92); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; "&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;myNumber += 1;      &lt;/span&gt;&lt;/li&gt;&lt;li class="alt"  style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-width: initial; border-color: initial; list-style-type: decimal-leading-zero; list-style-image: initial; list-style-position: outside !important; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); padding-top: 0px !important; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; line-height: 14px; background-color: rgb(255, 255, 255);  color:inherit;"&gt;&lt;span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: black; background- color:inherit;"&gt;}  &lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;So even though by default overflow checking is enabled for the entire project, it is not for this particular block.&lt;/p&gt;&lt;p&gt;I hope that you found this little bit of C# trivia interesting, even though most of us won't ever need to fiddle with these settings, it is nice to know what we have available to us.&lt;/p&gt;&lt;p&gt;source : http://www.codethinked.com&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-1092819343374269476?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/1092819343374269476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=1092819343374269476&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/1092819343374269476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/1092819343374269476'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/c-trivia-what-no-overflow.html' title='C# Trivia - What? No Overflow?'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-6325161600259338858</id><published>2009-01-13T10:12:00.000-08:00</published><updated>2009-01-13T10:15:39.052-08:00</updated><title type='text'>A DISSERTATION ON .NET PROPERTIES</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I’ve been meaning to write this piece for quite some time. Today we’re going to discuss properties in general, and specifically what are referred to as “trivial” properties.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The Technology Behind Properties&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Chances are you can skip this part if you have any .NET development experience.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Properties are specially-demarcated methods in a given .NET class. When your class is used by another piece of code, the property looks and acts much like a field or variable.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Let’s examine a snippet of code:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public class Class1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public int PublicValue;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    private int myValue;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public int Value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        get { return myValue; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        set { myValue = value; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;In this code, we define a very simple class. This class has one public “field” and one public “property.” The property defines a “getter” and “setter” for its data. When using this class, we might use code such as:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public static void Main()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    Class1 c = new Class1();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    c.PublicValue = 5;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    c.Value = 10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;So from the client programmer’s perspective, a public field and a public property more-or-less look the same. What’s the difference “under the hood?”&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;If you use ILDASM (the Intermediate Language Disassembler, which ships with the .NET Software Development Kit), you will see the following fields (cyan rectangle) of Class1:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PublicValue : public int32&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myValue : private int32&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;You’ll see the following methods (purple rectangles):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.ctor : void()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get_Value : int32()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;set_Value : void(int32)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;And the following property definition:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.property instance int32 Value()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The property definition ties the two get/set methods together as a property for .NET languages. You can see this if you look at the MSIL definition of the property:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.property instance int32 Value()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .get instance int32 DemoClasses.Class1::get_Value()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .set instance void DemoClasses.Class1::set_Value(int32)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;} // end of property Class1::Value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;OK, so what does writing the extra code for a property actually buy you? You have the ability to add logic to the property, to ensure business rules are followed. You can also use it, on reference types, to ensure that no null values are returned.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Also, if you want to use object binding, you have to use properties – you can’t use public fields for binding.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Designing Properties&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;So now you know the basics of how properties work. What are some basic guidelines?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I believe that properties exist to make your life, and the lives of the client developers using your class, easier. To this end, here are John’s Simple Rules of Properties:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Properties shall never return null, unless there is a damn good reason to do so. If your property has to return null for some reason, then document it – use the documentation feature of C# or VB to do so.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Generally, properties should enforce business rules. If you have a numeric value with logical minimums and maximums, enforce them. If the string must have a certain length, enforce that. It’s OK to throw exceptions from the set block, or – if applicable – modify the value accordingly (truncation, etc). However, document any and all side effects which are possible.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Trivial Properties&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Which brings us to “trivial” properties. Trivial properties are ones such as that which we wrote above – there’s no logic, no nothing, the get simply returns whatever value is in the backing store and the set simply sets the backing store.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I am generally against trivial properties. I’m not against writing the code, but I am against using a property without taking advantage of its benefits.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Automatic Properties&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Starting with Visual Studio 2008 and .NET 3.0, C# provides the concept of “automatic” properties. “Automatic” properties look something like this:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public class Class1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public int Value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        get;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        set;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    public string Text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        get;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        set;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Notice that we wrote almost no code there. When we compile, the compiler will generate the full property for us. Let’s see what the disassembly looks like.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;First there are the fields. We didn’t define any in our class, but we have some:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;text&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField : private string&lt;/span&gt;&lt;/span&gt;&lt;/text&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;value&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField : private int32&lt;/span&gt;&lt;/span&gt;&lt;/value&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;These are the backing stores for the properties. As for the property methods themselves:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get_Text : string()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;get_Value : int32()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;set_Text : void(string)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;set_Value : void(int32)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;And finally the properties themselves:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Text : instancestring()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Value : instance int32()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;That’s all well and good, but what do these properties actually do? Well, simply put, .NET’s automatic properties create “trivial” properties – the bare minimal get/set blocks. Running the code through ILDASM, here’s the output for the Text property:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.method public hidebysig specialname instance string &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        get_Text() cil managed&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  // Code size       7 (0x7)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .maxstack  8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0000:  ldarg.0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0001:  ldfld      string DemoClasses.Class1::'&lt;/span&gt;&lt;/span&gt;&lt;text&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField'&lt;/span&gt;&lt;/span&gt;&lt;/text&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0006:  ret&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;} // end of method Class1::get_Text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.method public hidebysig specialname instance void &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        set_Text(string 'value') cil managed&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  // Code size       8 (0x8)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  .maxstack  8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0000:  ldarg.0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0001:  ldarg.1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0002:  stfld      string DemoClasses.Class1::'&lt;/span&gt;&lt;/span&gt;&lt;text&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField'&lt;/span&gt;&lt;/span&gt;&lt;/text&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  IL_0007:  ret&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;} // end of method Class1::set_Text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Looking at the MSIL, they do nothing but set and return the backing store. There is no logic, no null checks, no nothing. We can confirm this by running the entire class through Reflector. (Every .NET developer should have Reflector installed.) Here’s the output:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;public string Text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    [CompilerGenerated]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    get&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        return this.&lt;/span&gt;&lt;/span&gt;&lt;text&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField;&lt;/span&gt;&lt;/span&gt;&lt;/text&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    [CompilerGenerated]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    set&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;        this.&lt;/span&gt;&lt;/span&gt;&lt;text&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;k__BackingField = value;&lt;/span&gt;&lt;/span&gt;&lt;/text&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;When using this class, therefore, it’s entirely possible to have null returned – so the client developer potentially has to do null checks to avoid NullReferenceExceptions. This violate’s John’s First Rule of Properties.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;So in conclusion, properties in general are good and useful, but only if you’re using them effectively. Automatic properties are, in my mind, to be avoided as they generate trivial properties.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;source: &lt;a href="http://codeheaven.info"&gt;http://codeheaven.info&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-6325161600259338858?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/6325161600259338858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=6325161600259338858&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/6325161600259338858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/6325161600259338858'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/ive-been-meaning-to-write-this-piece.html' title='A DISSERTATION ON .NET PROPERTIES'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7307193957300897778.post-615857341707833079</id><published>2009-01-11T07:15:00.001-08:00</published><updated>2009-01-11T07:15:46.219-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='asp.net performance'/><title type='text'>ASP.NET Performance Tips</title><content type='html'>&lt;span class="Apple-style-span" style="color: rgb(85, 85, 68); font-family: 'Lucida Sans Unicode'; font-size: 12px; line-height: 19px; "&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;In the post below I am going to run down a short-list of some of the less-popular performance tips and the reasoning behind them.  There are loads of blog postings and articles on asp.net performance enhancements, and I urge you to check those out as well.  Onto the good stuff...&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;&lt;strong&gt;Session.ReadWrite versus Session.ReadOnly&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;It goes without saying that using the Session object will incur some performance overhead so if possible it should be turned off in the web.config.  &lt;br /&gt;That said, If you’re using the Session object to maintain session in your application...  &lt;br /&gt;Ensure Session.ReadOnly is true rather than using Session.ReadWrite across the application.  There is more information in the link below, however the short story is there is no ReadWriterLock done if Session.ReadOnly = true.  From &lt;a href="http://msdn.microsoft.com/en-us/library/bz6sth95(VS.71).aspx" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;this MSDN link&lt;/a&gt;, “ReaderWriterLock allows multiple threads to read a resource concurrently, but requires a thread to wait for an exclusive lock in order to write to the resource.”  This will make a fairly significant difference if sessions are being managed in a state database, in which case only one-trip to the database is made when using ReadOnly, rather than two while using ReadWrite...which leads me to...&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;&lt;strong&gt;Optimizing your Session when using Out-Of-Process (E.g., State Server or State Database) Session Management&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;When using out-of-process session management methods objects must be serialized on their way into the state server or state database.  Naturally, this means the data within the session object must be deserialized on the way back out [to the application].  In order for this to work you'll need to add the [Serializable] attribute to the beginning of the class that needs to go into the session object.  For example...&lt;/p&gt;&lt;div face="consolas, 'Courier New', courier, monospace" size="8pt" color="initial" style="border-right-color: gray; border-top-color: gray; overflow-x: auto; overflow-y: auto; border-left-color: gray; width: 97.5%; cursor: text; line-height: 12pt; border-bottom-color: gray; background-color: rgb(244, 244, 244); max-height: 200px; margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; "&gt;&lt;div face="consolas, 'Courier New', courier, monospace" size="8pt" color="initial" style="overflow-x: visible; overflow-y: visible; width: 100%; color: black; line-height: 12pt; background-color: rgb(244, 244, 244); margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; "&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; color: white; "&gt;[Serializable]&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;&lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;class&lt;/span&gt; User{&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; color: white; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; firstName; &lt;span style="color: rgb(0, 128, 0); "&gt;//Small text field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; lastName; &lt;span style="color: rgb(0, 128, 0); "&gt;//Another small text field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; color: white; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; usersLifeStory; &lt;span style="color: rgb(0, 128, 0); "&gt;//Is a large text field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;As you may infer from my not-so-clever comments, there may be a problem with this.  Let's say the user object needs to be stored in my session object [and therefore needs to be serializable], but there are some large, or otherwise inefficient fields in this object (such as non-primitive types).  For the purposes of this example, let's also say that I don't need to store my user's life story in my session object because it's only displayed on one page where I can pull it from the application's database.  The .NET framework makes it very easy to exclude properties within my object from being serialized.  In fact, it's as easy as adding a few more attributes. &lt;/p&gt;&lt;div style="font-size: 8pt; overflow-x: auto; overflow-y: auto; width: 97.5%; cursor: text; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: rgb(244, 244, 244); max-height: 200px; margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-bottom: 1.2em; "&gt;&lt;div style="font-size: 8pt; overflow-x: visible; overflow-y: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: rgb(244, 244, 244); margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-bottom: 1.2em; "&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; color: white; "&gt;[Serializable]&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;&lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;class&lt;/span&gt; User{&lt;/pre&gt;&lt;pre face="consolas, 'Courier New', courier, monospace" size="8pt" color="white" style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; firstName; &lt;span style="color: rgb(0, 128, 0); "&gt;//Small text field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; lastName; &lt;span style="color: rgb(0, 128, 0); "&gt;//Another small text field&lt;/span&gt;&lt;/pre&gt;&lt;pre face="consolas, 'Courier New', courier, monospace" size="8pt" color="white" style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; "&gt;    [NonSerialized]  &lt;span style="color: rgb(0, 128, 0); "&gt;//Prevents usersLifeStory from being serialized&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; font-family: consolas, 'Courier New', courier, monospace; font-size: 8pt; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; usersLifeStory; &lt;span style="color: rgb(0, 128, 0); "&gt;//Is a large text field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none; "&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Easy peasy.  Note that this means the "usersLifeStory" variable will not be accessible via the session object, of course.&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;&lt;strong&gt;Cache and...&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;think about your caching strategy before you go developing pages or user controls willy nilly.  This will make using the .NET frameworks caching features much easier and will hopefully prevent you from having to make some logic work differently just so you can cache...this will make life especially easy when using features like &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/11/28/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature.aspx" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;output cache substitution&lt;/a&gt; and creating methods/strategies for querying your DB.  Again, caching is something you should be thinking about before you launch your IDE.&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;There are tons of resources for learning about output caching, data caching, and the other features the .NET framework provides, so I'm going to skip that.  I am, however, going to mention a really easy way to automagically cache return values from WebMethods/Web-services because I don't see it mentioned very much. &lt;/p&gt;&lt;div style="font-size: 8pt; overflow-x: auto; overflow-y: auto; width: 97.5%; cursor: text; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: rgb(244, 244, 244); max-height: 200px; margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-bottom: 1.2em; "&gt;&lt;div style="font-size: 8pt; overflow-x: visible; overflow-y: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: rgb(244, 244, 244); margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-bottom: 1.2em; "&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none; "&gt;&lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;class&lt;/span&gt; ExampleService{&lt;/pre&gt;&lt;pre face="consolas, 'Courier New', courier, monospace" size="8pt" style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; "&gt;    &lt;span style="color: rgb(0, 128, 0); "&gt;//The cache duration attribute handles ALL caching for you&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none; "&gt;    &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; "&gt;    [System.Web.Services.WebMethod(CacheDuration=60)]&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none; "&gt;    &lt;span style="color: rgb(0, 0, 255); "&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255); "&gt;string&lt;/span&gt; GetSomethingFromSomewhere(){&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; "&gt;        &lt;span style="color: rgb(0, 128, 0); "&gt;//Logic to get some data from a data-source&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none; "&gt;    }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; overflow-x: visible; overflow-y: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: rgb(244, 244, 244); border-bottom-style: none; "&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;That's it...Just add the &lt;a href="http://msdn.microsoft.com/en-us/library/byxd99hx(VS.71).aspx" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;CacheDuration&lt;/a&gt; attribute and you're good to go.&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;Update [1/5/2009]: Scott Mitchell has just posted a great, and concise article on per-request-caching.  This is easy-to-use and powerful functionality.  Read the article &lt;a href="http://dotnetslackers.com/articles/aspnet/Caching-Data-During-the-Lifespan-of-a-Request.aspx" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;&lt;strong&gt;Use HTTP Compression!!!&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;Maybe it's the luck of the draw here, but in my experiences most developers/sys admins/etc for some reason or another don't enable HTTP Compression, either &lt;a href="http://en.wikipedia.org/wiki/DEFLATE" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;deflate&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Gzip" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;GZIP&lt;/a&gt;.  I'm sure there are some legitimate reasons for not enabling this functionality for some applications, but everyone else should absolutely have it turned on.  Yes, it's going to cost some CPU but you can play with the settings.  Bottom line is you will see a dramatic difference in page response times.  Keep in mind you can configure HTTP Compression to compress a number of file-types, including CSS/JS/HTML/ASPX/ASMX/ASHX etc. &lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;Also, I came across &lt;a href="http://www.webpronews.com/expertarticles/2006/12/08/gzip-vs-deflate-compression-and-performance" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;this post&lt;/a&gt; doing some research the other night - looks like Mads did some testing on GZIP versus Deflate.  The results are interesting...I have yet to do some testing on my end.&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;For some reason or another the IIS6 team didn't give us an GUI to turn on/off HTTP Compression, so you need to go into the metabase.  It's really only confusing the first time you do it.  There are a number of good tutorials on the web.  I think &lt;a href="http://www.dotnetjunkies.com/HowTo/16267D49-4C6E-4063-AB12-853761D31E66.dcik" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;this&lt;/a&gt; is the one I used.  You'll probably want to ensure HTTP Compression is on by using a tool like &lt;a href="http://www.httpwatch.com/download/" target="_blank" style="font-weight: bold; text-decoration: none; color: rgb(102, 153, 34); background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: transparent; background-position: initial initial; "&gt;HTTPWatch&lt;/a&gt;, or its FireFox equal...the name of which currently slips my mind.  Google is your friend :)&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;&lt;strong&gt;Be careful with the App_Themes folder!&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-right: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 140%; margin-top: 5px; margin-bottom: 1em; "&gt;I don't have any screen shots handy, and I'm not at my office so you're going to have to trust me on this but...Be careful what you put into app_themes.  No matter what you reference in your pages using the&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7307193957300897778-615857341707833079?l=dot-net-spider.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dot-net-spider.blogspot.com/feeds/615857341707833079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7307193957300897778&amp;postID=615857341707833079&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/615857341707833079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7307193957300897778/posts/default/615857341707833079'/><link rel='alternate' type='text/html' href='http://dot-net-spider.blogspot.com/2009/01/aspnet-performance-tips.html' title='ASP.NET Performance Tips'/><author><name>Oracle</name><uri>http://www.blogger.com/profile/12315235944344904963</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_J8SXoQteMhQ/SWhfBkmAwKI/AAAAAAAACQg/71s6YO2VT3E/S220/The_Oracle_(i).gif'/></author><thr:total>0</thr:total></entry></feed>
