<?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-5119957131131393001</id><updated>2012-02-16T16:55:24.245-08:00</updated><category term='Windows XP'/><category term='Windows Vista'/><category term='Model View Presenter'/><category term='MVVM'/><category term='MVC'/><category term='Performance'/><category term='YAGNI'/><category term='Decorator Pattern'/><category term='Facade Pattern'/><category term='MVP'/><category term='Generics'/><category term='C#'/><category term='SSL 3.0'/><category term='architectural patterns'/><category term='TLS 1.0'/><category term='TCP'/><category term='WCF'/><category term='Bindings'/><category term='Model View ViewModel'/><category term='Model View Controller'/><category term='SSL'/><category term='Enum'/><category term='Bridge Pattern'/><category term='.NET'/><category term='Presentation Model'/><title type='text'>The Spot</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-6263330462876037025</id><published>2009-09-26T10:35:00.000-07:00</published><updated>2009-09-26T23:55:08.457-07:00</updated><title type='text'>Hannibal the Cannibal on Class and Method Design</title><content type='html'>&lt;div&gt;Everything I know about class and method design I learned from Hannibal Lecter. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;OK that's not exactly true, but the first, most basic, and in many ways most important thing that I learned about class and method design I learned from the good doctor. Before there was IoC, dependency injection, MVC, MVP, the &lt;a href="http://www.oodesign.com/open-close-principle.html"&gt;Open Close Principal&lt;/a&gt;, or &lt;a href="http://www.oodesign.com/liskov-s-substitution-principle.html"&gt;Liskov's Substitution Principal&lt;/a&gt;. Before there was even encapsulation and loose coupling, there was Hannibal Lecter's First Principle:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-3c554abc2d2262bc" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v22.nonxt7.googlevideo.com/videoplayback?id%3D3c554abc2d2262bc%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D3A2137993EF5DDF4FCA82648EBD83B58852DD81D.6EDE1F5E419A840FF3DAC6CCBEAD474577BE688F%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D3c554abc2d2262bc%26offsetms%3D5000%26itag%3Dw160%26sigh%3DYjENb4mAjCY-kYmB7csVUXnp_d4&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v22.nonxt7.googlevideo.com/videoplayback?id%3D3c554abc2d2262bc%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D3A2137993EF5DDF4FCA82648EBD83B58852DD81D.6EDE1F5E419A840FF3DAC6CCBEAD474577BE688F%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D3c554abc2d2262bc%26offsetms%3D5000%26itag%3Dw160%26sigh%3DYjENb4mAjCY-kYmB7csVUXnp_d4&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As software developers we live in a world of unbounded complexity. Most of the design principles that we have developed over the years represent, at their heart, our effort to beat down and shackle that complexity: to build walls around complex systems and declare, "Beyond this point none shall pass!"(encapsulation), to clearly define responsibilities, declaring "&lt;i&gt;A&lt;/i&gt; shall do thus, and &lt;i&gt;B&lt;/i&gt; shall do thus, and never shall the one take up the task of the other" (abstraction, loose coupling, MVC, MVP). We keep these ideas ever in our minds as we develop the classes and methods that implement the solutions that earn us our daily bread. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But the advice we should turn to most often is that of Hannibal Lecter. His words should ring in our ears throughout each day: each thing that we develop, each method, each class -- &lt;i&gt;what is it&lt;/i&gt;? Step back from the problem you are trying to solve for a moment, and look at each one of our little creations in isolation. Each is deserving of its own identity, its own purpose, its own place in the cosmos. Each deserves to have a life of its own, unique and independent of the lives of its brothers and sisters. Software is complex enough without having to remember the particular problem that the author of a class or method was working on at the time he or she wrote it. As Abraham Lincoln once said, "the world will little note nor long remember the context in which the method was written, but the method itself will live on." &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Sometimes it's not easy to step back and focus on the individual pieces of our solution in isolation from the rest. It takes a change of gears, a certain adjustment of perspective. In the following clip we see Hannibal guide Clarice in finding the true essence of the class she's working on. As with many of the good doctor's creations, it may be best that we don't try to guess its exact purpose, though it does appear to be a subclass of a class called "Man":&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-52d0e664d5869ed6" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v13.nonxt6.googlevideo.com/videoplayback?id%3D52d0e664d5869ed6%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D10E33AC20E185498C0DCDB3313216C1A87920B7A.F29D8D11623E68C6BC237FF17CF0C3C62694BFF%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D52d0e664d5869ed6%26offsetms%3D5000%26itag%3Dw160%26sigh%3DDCsPKTrWDHopGdu7zfvvQS4fMWQ&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v13.nonxt6.googlevideo.com/videoplayback?id%3D52d0e664d5869ed6%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D10E33AC20E185498C0DCDB3313216C1A87920B7A.F29D8D11623E68C6BC237FF17CF0C3C62694BFF%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D52d0e664d5869ed6%26offsetms%3D5000%26itag%3Dw160%26sigh%3DDCsPKTrWDHopGdu7zfvvQS4fMWQ&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As always, the good doctor gets straight at the heart of the matter. The purpose of this class is not to be found in the particular use to which it's currently being put. It has a more basic, more fundamental nature.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At this point it may be best not to try to draw concrete examples out of the problem Hannibal and Clarice are working on. Instead, I'll give three brief examples from some code I reviewed just last week. The names of the methods and the classes will of course be changed to protect the innocent: these types of problems disturb the good doctor greatly, and it's best not to upset him.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; HannibalsFirstPrinciple&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ViolationNumberOne&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:green;"&gt;// Called before running the batch process&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Foo()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:green;"&gt;// Does some stuff&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;Any time you see a comment like the one on the public method "Foo" shown here, alarm bells should start ringing in your head. You don't have to read the method body to know that Hannibal's First Principle has been violated.&lt;i&gt; This is a public method on a public class&lt;/i&gt;. Who's to say that Foo will always be called before running the batch process? The client can call Foo whenever it likes! And what the heck is "the batch process" anyway? It sounds like some piece of some particular problem the author of this class was working on at the time he or she created it. Clearly the author wrote this with a single-minded focus on one particular problem that he or she was working on, and never took the time to think about &lt;i&gt;what this class is in and of itself&lt;/i&gt;. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This programmer would not be producing code of this sort today if he or she had studied under doctor Lecter. Here's another example:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; HannibalsFirstPrinciple&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; Amount { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ViolationNumberTwo&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;const&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; MAX_ACCOUNT_AMOUNT = 10000;&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; ValidateAccounts()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;var&lt;/span&gt; account = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt;() { Amount = 5000 };&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(IsAccountOverTheLimit(account.Amount, MAX_ACCOUNT_AMOUNT));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; IsAccountOverTheLimit(&lt;span style="color:blue;"&gt;int&lt;/span&gt; value1, &lt;span style="color:blue;"&gt;int&lt;/span&gt; value2)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt; value1 &gt; value2;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Consider the method IsAccountOverTheLimit. In the context of the entire program, it seems reasonable enough: it checks the amount in an account against the maximum value allowed. But what does it really do? In fact, IsAccountOverTheLimit itself has nothing to do with accounts or limits at all. It simply compares two integers; it's the client that gives these particular meanings to the method. Had the author studied under doctor Lecter (and survived), he or she would have written the method this way:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 255);"&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; IsAccountOverTheLimit(&lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt; account)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt; account.Amount &gt; MAX_ACCOUNT_AMOUNT;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 255);font-family:Georgia,serif;font-size:6;"&gt;&lt;span class="Apple-style-span" style="font-size:19;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 0);font-family:'Courier New';font-size:130%;"&gt;&lt;span class="Apple-style-span" style="font-size:16;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Or perhaps this way:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; IsGreaterThan(&lt;span style="color:blue;"&gt;this&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; thisNumber, &lt;span style="color:blue;"&gt;int&lt;/span&gt; numberToCompere)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt; thisNumber &gt; numberToCompere;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span class="Apple-style-span"  style=";font-family:Georgia,serif;font-size:6;"&gt;&lt;span class="Apple-style-span" style="font-size:19;"&gt;&lt;span class="Apple-style-span"  style=";font-family:'Courier New';font-size:130%;"&gt;&lt;span class="Apple-style-span" style="font-size:16;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Either make the method a full-fleshed citizen of the world by giving it all the rights and responsibilities implied by its name, or change its name so that it can declare its true purpose in life with honesty and dignity.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And the final example gets to the heart of understanding the essence of a class, and of maintaining its simplicity:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; HannibalsFirstPrinciple&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; _amount;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; _isInterestBearing;&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; Account() { }&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; Account(&lt;span style="color:blue;"&gt;bool&lt;/span&gt; isInterestBearing)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_isInterestBearing = isInterestBearing;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; Amount&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt; _isInterestBearing ? (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)(1.1 * _amount) : _amount;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;set&lt;/span&gt; { _amount = &lt;span style="color:blue;"&gt;value&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The programmer here as cluttered up a perfectly good Account class with a lot of extra nonsense that many clients of the class probably don't care about. If you have a special use for a class, specialize it! Don't introduce complexity when simplicity will do:&lt;/div&gt;&lt;div&gt;&lt;div style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span class="Apple-style-span"  style=";font-family:Georgia,serif;font-size:6;"&gt;&lt;span class="Apple-style-span" style="font-size:19;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; HannibalsFirstPrinciple&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; Amount { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;InterestBearingAccount&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;Account&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; _amount;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; Amount&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;get&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt; (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)(1.1 * _amount);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;set&lt;/span&gt; { _amount = &lt;span style="color:blue;"&gt;value&lt;/span&gt;; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These examples seem silly and simplistic because they've been constructed to shine the light of day on these problems, but in the real world these anti-patterns can easily hide amid the complexity of our code, and it's important to note that I saw examples like these in real production code just this week. These types of problems can bite any of us unless we keep our vigilance, unless we keep doctor Lecter's words of wisdom ever ringing in our ears. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Or if doctor Lecter has used too many words for you to remember, then at least remember this exhortation by one of his students, who has clearly grasped the essence and urgency of his lesson:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-df7a56ce1f921aea" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v5.nonxt2.googlevideo.com/videoplayback?id%3Ddf7a56ce1f921aea%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D5160FFA67DE26CCBE583E39CC4493157D0B7E402.468B235FC1F7C35F824A9D917343E8C5949DF89F%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Ddf7a56ce1f921aea%26offsetms%3D5000%26itag%3Dw160%26sigh%3DJK6rZHFXwGSP3iH7LxeTVcjj8ps&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v5.nonxt2.googlevideo.com/videoplayback?id%3Ddf7a56ce1f921aea%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D5160FFA67DE26CCBE583E39CC4493157D0B7E402.468B235FC1F7C35F824A9D917343E8C5949DF89F%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Ddf7a56ce1f921aea%26offsetms%3D5000%26itag%3Dw160%26sigh%3DJK6rZHFXwGSP3iH7LxeTVcjj8ps&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Safe and happy coding all!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-6263330462876037025?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/6263330462876037025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/09/hannibal-cannibal-on-class-and-method.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/6263330462876037025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/6263330462876037025'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/09/hannibal-cannibal-on-class-and-method.html' title='Hannibal the Cannibal on Class and Method Design'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-4077409116061626935</id><published>2009-06-23T23:29:00.001-07:00</published><updated>2009-06-25T12:44:12.563-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows Vista'/><category scheme='http://www.blogger.com/atom/ns#' term='Bindings'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows XP'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Effect on WCF web service performance of the Tcp window size in high-latency Windows networks</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkPTUYx5IAI/AAAAAAAAATw/msrBjtJUJSE/s1600-h/wireshark10.jpg"&gt;&lt;/a&gt;&lt;div style="text-align: left;"&gt;In my &lt;a href="http://computing-tombarreras.blogspot.com/2009/05/wcf-bug-on-w2k3-and-xp-tcp-session.html"&gt;last post&lt;/a&gt; I looked at the effect of a bug in WCF on Windows XP and W2K3, in which the Tcp connection used by web services that use TransferMode "Streamed" or "StreamedRequest" is closed after every call. This forces subsequent calls to re-establish the Tcp and, if in use, SSL connection(s) at the start of every call, which can have serious performance consequences.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;TCP Window Size and Performance on High-Latency Networks&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;As a follow-up, I'd like to look at the effect of adjusting the Tcp window size on performance. &lt;a href="http://support.microsoft.com/kb/224829%3ETcp%20window%20size%3C/a%3E%20on%20high-latency%20Windows%20networks.%20Pages%20such%20as%20%3Ca%20href=" com="" us="" library=""&gt;This &lt;/a&gt;and &lt;a href="http://www.speedguide.net/read_articles.php?id=157"&gt;this&lt;/a&gt; do an excellent job of describing what the Tcp window is, how it affects Tcp traffic in high-latency, high-bandwidth environments, and how to set it. I won't try to duplicate all that here, except to quote as a brief overview two snippets from &lt;a href="http://support.microsoft.com/kb/224829"&gt;this MSDN article&lt;/a&gt; on it:&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;b&gt;TCP window size&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The TCP receive window size is the amount of receive data (in bytes) that can be buffered during a connection. The sending host can send only that amount of data before it must wait for an acknowledgment and window update from the receiving host. The Windows TCP/IP stack is designed to self-tune itself in most environments, and uses larger default window sizes than earlier versions.&lt;/div&gt;&lt;div&gt;....&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Windows scaling&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For more efficient use of high bandwidth networks, a larger TCP window size may be used. The TCP window size field controls the flow of data and is limited to 2 bytes, or a window size of 65,535 bytes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since the size field cannot be expanded, a scaling factor is used. TCP window scale is an option used to increase the maximum window size from 65,535 bytes to 1 Gigabyte.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The window scale option is used only during the TCP 3-way handshake. The window scale value represents the number of bits to left-shift the 16-bit window size field. The window scale value can be set from 0 (no shift) to 14.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To calculate the true window size, multiply the window size by 2^S where S is the scale value.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;For Example: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the window size is 65,535 bytes with a window scale factor of 3. &lt;/div&gt;&lt;div&gt;True window size = 65535*2^3&lt;/div&gt;&lt;div&gt;True window size = 524280&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;Increasing this setting in high-latency, high-bandwidth environments can help improve performance because it helps prevent the sender from delivering all the bytes in its buffer before the receiver has a chance to acknowledge receipt of the packets. When that happens the sender has to pause until the ACKs start coming in, resulting in a herky-jerky, slow connection.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;What the Tcp Window Size Affects&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One thing I didn't understand about the Tcp Window Size setting until I conducted these tests is that it is a &lt;i&gt;receive &lt;/i&gt;buffer. When configured on machine A, it tells any potential sending machine B the size of the buffer &lt;i&gt;it &lt;/i&gt;should use when sending data to machine A. This was unintuitive to me. Also, machines A and B can use different Tcp window sizes during the same connection. Machine A uses the buffer size configured on machine B when machine A sends data to B, and machine B uses the buffer configured on machine A when machine B sends data to A.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style=" ;font-size:large;"&gt;Testing the Affect of Various Tcp Window Sizes&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following tests were conducted with a WCF service host running on Windows XP, with a Vista client. The Tcp window size can't be configured on Vista (or W2K8) the way it can on XP and W2K3; Microsoft has replaced it with &lt;a href="http://blogs.msdn.com/wndp/archive/2006/05/05/Winhec-blog-tcpip-2.aspx"&gt;Tcp Window Auto-tuning&lt;/a&gt;, which they believe renders the TcpWindowSize registry setting obsolete. We'll take a look at that as well. The tests were all conducted using 250ms latency simulated using the &lt;a href="http://wanem.sourceforge.net/"&gt;WANemulator&lt;/a&gt;, on a wireless 8011n network with approximately 30 Mbits of bandwidth.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The tests use essentially the same simple WCF client and host application that I used in my last post, except that I now have 3 web services instead of 1:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;GetStringData&lt;/i&gt;: A simple web service that takes a string parameter and returns it in its return value. I run two tests with this service, one in which I transfer a small "Hi mom" string back and forth, and one in which I transfer a larger string, a 277KB JPEG of my daughter:&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkHRdW2yW6I/AAAAAAAAAPo/05RNfijQTrI/s400/Katie.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5350788134574644130" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 238px; height: 400px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;My daughter Kaitlin&lt;/i&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;GetStreamedData&lt;/i&gt;: A web service that gets a Stream from the server.&lt;/li&gt;&lt;li&gt;&lt;i&gt;PutStreamedData:&lt;/i&gt; A web service that sends a Stream to the server.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;For these tests I'm using GetStreamedData and PutStreamedData to transfer a 3.9 MB movie of a bear:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-e3091ba8c2e1330b" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v21.nonxt3.googlevideo.com/videoplayback?id%3De3091ba8c2e1330b%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D2503B4B019F312E85DADFE4D6D148C8BB1AB7B52.6E5497B7ABDA8452E4E9087924B8B6A3540EEEC4%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3De3091ba8c2e1330b%26offsetms%3D5000%26itag%3Dw160%26sigh%3DSjFN3s2PUd6REK2LTyAF_rwvruc&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v21.nonxt3.googlevideo.com/videoplayback?id%3De3091ba8c2e1330b%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331593679%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D2503B4B019F312E85DADFE4D6D148C8BB1AB7B52.6E5497B7ABDA8452E4E9087924B8B6A3540EEEC4%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3De3091ba8c2e1330b%26offsetms%3D5000%26itag%3Dw160%26sigh%3DSjFN3s2PUd6REK2LTyAF_rwvruc&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;A bear&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Both the picture of Kaitlin and the bear video are already compressed, so there's no worry about anyone else compressing them again and skewing the results.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;The Test WCF Host Application&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;As before, the WCF host, which is running on the XP machine, is a simple console app:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMm50dgfuI/AAAAAAAAASQ/TNO9M31Pop0/s1600-h/host.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMm50dgfuI/AAAAAAAAASQ/TNO9M31Pop0/s400/host.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351163557023088354" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 191px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Which hosts this service:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMnFqR_1-I/AAAAAAAAASY/creTSk2r_dc/s1600-h/streamingservice.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMnFqR_1-I/AAAAAAAAASY/creTSk2r_dc/s400/streamingservice.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351163760448886754" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 344px; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;That uses the following, simple bindings:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkMnS_TLdyI/AAAAAAAAASg/q4nBZXr0Ruc/s1600-h/serverbindings3.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkMnS_TLdyI/AAAAAAAAASg/q4nBZXr0Ruc/s400/serverbindings3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351163989429286690" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 196px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMnFqR_1-I/AAAAAAAAASY/creTSk2r_dc/s1600-h/streamingservice.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;The Test WCF Client Application&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The client uses similar bindings:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMnoaP6_tI/AAAAAAAAASw/UNOWY96Naxg/s1600-h/clientbidings2-1.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMnoaP6_tI/AAAAAAAAASw/UNOWY96Naxg/s400/clientbidings2-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164357440634578" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 168px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMnoH2DKoI/AAAAAAAAASo/GHCcjuMQwa0/s1600-h/clientbidings2-2.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMnoH2DKoI/AAAAAAAAASo/GHCcjuMQwa0/s400/clientbidings2-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164352500279938" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 111px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkMnS_TLdyI/AAAAAAAAASg/q4nBZXr0Ruc/s1600-h/serverbindings3.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;And is also a simple console app:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkMoMTUX4YI/AAAAAAAAATg/fVhuZCwAKfg/s1600-h/clientprogram5-6.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkMoMTUX4YI/AAAAAAAAATg/fVhuZCwAKfg/s400/clientprogram5-6.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164974055547266" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 152px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkMoCrh8o7I/AAAAAAAAATQ/OrpWTvQ2ZNk/s1600-h/clientprogram5-4.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkMoCrh8o7I/AAAAAAAAATQ/OrpWTvQ2ZNk/s400/clientprogram5-4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164808756241330" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 179px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoC1ce8rI/AAAAAAAAATY/Mdlqyso-Zv0/s1600-h/clientprogram5-5.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoC1ce8rI/AAAAAAAAATY/Mdlqyso-Zv0/s400/clientprogram5-5.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164811417678514" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 144px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCm2z8wI/AAAAAAAAATI/pV96p7_kgdQ/s1600-h/clientprogram5-3.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCm2z8wI/AAAAAAAAATI/pV96p7_kgdQ/s400/clientprogram5-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164807501574914" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 250px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCaKwldI/AAAAAAAAATA/MJA-9xXN1yQ/s1600-h/clientprogram5-2.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCaKwldI/AAAAAAAAATA/MJA-9xXN1yQ/s400/clientprogram5-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164804095579602" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 133px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCFZh-tI/AAAAAAAAAS4/RvrIys4HDLE/s1600-h/clientprogram5.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMoCFZh-tI/AAAAAAAAAS4/RvrIys4HDLE/s400/clientprogram5.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351164798520392402" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 259px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkMnoaP6_tI/AAAAAAAAASw/UNOWY96Naxg/s1600-h/clientbidings2-1.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Results of the Tests - XP&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;I exercised all of the web service calls against an XP machine that was configured to use Tcp Window scale modes of 0, 1, 2 and 3. A scale mode of "0" means Tcp1323Opts (the registry setting that enables Tcp Window sizes greater than 64K) is disabled, and the TcpWindowSize is the default value of roughly 64K. Scale mode 1 means TcpWindowSize is roughly 2^1 x 64K, scale mode 2 means TcpWindowSize is roughly 2^2 x 64K, etc.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The results for the PutStreamedData call are as follows:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkHcv-i6UnI/AAAAAAAAARo/5eZ17Ao_poE/s1600-h/putperf.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkHcv-i6UnI/AAAAAAAAARo/5eZ17Ao_poE/s400/putperf.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5350800549094249074" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 291px; " /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Seconds per PutStreamedData web service call, by TcpWindowSize scale mod&lt;/i&gt;e.&lt;i&gt; Click on the image to open it in a larger window.&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;This graph shows the amount of time each PutStreamedData web service call takes, based on the TcpWindowSize scale mode configured on the XP machine. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The three streamed transfer mode bindings perform the worst, with streamed NetTcp the worst of all. This matches what I found in my last post when I tested large string-based payloads (I was too lazy in that post to test web services that use Stream parameters). Binding performances get significantly better with a TcpWindowSize scale mode of 1, and after that there's no improvement. The other binding types all start out at about the same performance level, except for buffered NetTcp, which is the best of all. But they separate from one another as the TcpWindowSize is increased, and ultimately buffered BasicHttp and WS2007 perform the best, buffered NetTcp comes in second, and buffered BasicHttp with SSL comes in as the worst of the rest, but still much better than the streamed bindings. This differs from what I saw in my last post, where buffered  NetTcp was the runaway performance king in all tests.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Remember that the graph above represents streamed data moving from a Vista machine to an XP machine. The TcpWindowSize has been configured as a registry setting on the XP machine. During the Tcp handshake, it has been passed from the XP machine to the Vista machine, which uses it to determine how many bytes it can send at a time, before receiving ACKs from the XP machine.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Results of the Test - Vista&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Now let's look at how data that's sent from XP to Vista looks:  &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkHcvzVcgvI/AAAAAAAAARg/jeN_mmKqqFc/s1600-h/getperf.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkHcvzVcgvI/AAAAAAAAARg/jeN_mmKqqFc/s400/getperf.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5350800546084979442" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 291px; " /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Seconds per GetStreamedData web service call, by TcpWindowSize scale mode on the XP machin&lt;/i&gt;e&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Here we see the bindings sorting themselves into two groups. The results are much more variable when sending data from XP to Vista than they were in the other direction, but doesn't appear to vary based on the TcpWindowSize that was configured on the XP machine. This validates the idea that Vista is relying on Tcp Window Auto-tuning, and not the TcpWindowSize configured on the host machine, to optimize the connection.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;The Effect of Increased Tcp Window Sizes in a Packet Trace&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The fact that the Vista machine and XP machine are using different Tcp window sizes can easily be seen in this &lt;a href="http://www.wireshark.org/"&gt;Wireshark&lt;/a&gt; packet trace, taken before any TcpWindowSize registry setting was made:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMBjEz1atI/AAAAAAAAASA/hO5U0bAvXqg/s1600-h/wireshark9-1.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SkMBjEz1atI/AAAAAAAAASA/hO5U0bAvXqg/s400/wireshark9-1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351122484344482514" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 205px; " /&gt;&lt;/a&gt;&lt;i&gt;&lt;div style="text-align: center;"&gt;Packet trace of a GetStreamedData call showing the different Tcp window sizes requested by Vista and XP&lt;/div&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkMBiznxe2I/AAAAAAAAAR4/zYnhtLSrXks/s1600-h/wireshark9-2.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkMBiznxe2I/AAAAAAAAAR4/zYnhtLSrXks/s400/wireshark9-2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351122479730490210" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 204px; " /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Packet trace of a GetStreamedData call showing the window size adjusting upward as the call proceed&lt;/i&gt;s&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkPSturqO6I/AAAAAAAAATo/Q9Mg2qpTIqk/s1600-h/wireshark9-3.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkPSturqO6I/AAAAAAAAATo/Q9Mg2qpTIqk/s400/wireshark9-3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351352465313381282" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 205px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkMoMTUX4YI/AAAAAAAAATg/fVhuZCwAKfg/s1600-h/clientprogram5-6.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Packet trace of a PutStreamedData call showing the default 64KB window size being used when moving data from Vista to XP&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The alert reader may notice that the Tcp session didn't end between the two web service calls. That's because for this test I changed the client code to call both web service calls on the same connection, without closing the connection between calls.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;In my testing the Tcp window requested by Vista always had a scale mode of 2. &lt;a href="http://blogs.msdn.com/wndp/archive/2006/05/05/Winhec-blog-tcpip-2.aspx"&gt;This MSDN blog post&lt;/a&gt; says that Vista determines the scale mode based on the &lt;a href="http://en.wikipedia.org/wiki/Bandwidth-delay_product"&gt;bandwidth delay product&lt;/a&gt; (bandwidth times latency). Since my tests were all conducted with the same bandwidth and latency, it's not surprising that Vista chose the same scale mode throughout. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The effect of the smaller Tcp window size used by default on XP can be seen by running a few queries in Wireshark. The total number of bytes transferred by the GetStreamedData and PutStreamedData calls are nearly identical, 5394699 v. 5394714. They are, after all, transmitting the same file across the network. But if you set the Wireshark filter to search for packets that arrived 0.2 seconds or more after the previous packet (frame.time_delta &gt; 0.2), you see that only 3 such instances occurred during the GetStreamedData call (the one that used the larger Tcp window), while 20 occurred during the PutStreamedData call. Here's one of them:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkPTUYx5IAI/AAAAAAAAATw/msrBjtJUJSE/s1600-h/wireshark10.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SkPTUYx5IAI/AAAAAAAAATw/msrBjtJUJSE/s400/wireshark10.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5351353129448841218" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 204px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Packet trace showing communication pausing due to a full buffer&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;These quarter-second pauses (equal to our round trip latency time) represent moments when the sender has completely filled its buffer and must wait for an ACK before continuing. And the discrepancy in frame time deltas is even more widespread than these 20 incidents: there are 48 deltas greater than 0.1 in the PutStreamedData communication to only 35 for GetStreamedData; 132 greater than 0.05 for PutStreamedData to 51 for GetStreamedData; 421 greater than 0.01 for PutStreamedData to 89 for GetStreamedData, and 679 greater than 0.001 for PutStreamedData to 430 for GetStreamedData. These pauses indicate delays in the communication caused by the sender's buffer momentarily filling up.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Summary of Findings on Stream Parameter Types&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;So to list some take-aways from the two graphs above:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="text-decoration: underline;"&gt;Based on the PutStreamedData graph (Vista to XP data transfer)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;It would appear that WCF on XP has particularly poor performance when streamed transfer modes are used. The buffered transfer modes out-perform their streamed counterparts by 50%-75%&lt;/li&gt;&lt;li&gt;For buffered BasicHttp, SSL doesn't add any appreciable overhead in the default case, but when the Tcp window size is optimally configured buffered BasicHttp is 50% faster than buffered BasicHttp with SSL&lt;/li&gt;&lt;li&gt;Under the default configuration, buffered NetTcp performs best, but when optimally configured buffered BasicHttp and WS2007 perform about 40% better than buffered NetTcp.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="text-decoration: underline;"&gt;Based on the GetStreamedData graph (XP to Vista data transfer)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;WCF on Vista appears to have particularly poor performance when SSL is used. The two bindings that use SSL perform worse than their non-SSL counterparts by 70%-75%. This is for me the most surprising finding of this entire exercise, because there was no indication that this would be the case in the large string-based payload tests that I conducted in my last post.&lt;/li&gt;&lt;li&gt;Streamed NetTcp is the next worst-performing binding, about 50% worse than buffered NetTcp. No surprise there as that binding has consistently performed terribily in all the testing I've done.&lt;/li&gt;&lt;li&gt;The other bindings perform roughly the same, about 50% better than the three worst-performing ones.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Mysteriously Poor Performance of SSL on Vista&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;As to why SSL-based bindings perform so poorly on Vista I'm at a loss to say, other than to note that I see similar-looking communications pauses in the SSL-based Wireshark traces. In one example, comparing a GetStreamedData call made by buffered BasicHttp and buffered BasicHttp with SSL:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;6554 packets transfered in the non-SSL case, 6704 for SSL&lt;/li&gt;&lt;li&gt;Pauses greater than 0.01 seconds: 194 in the non-SSL case, 225 for SSL&lt;/li&gt;&lt;li&gt;Pauses greater than 0.1 seconds: 17 in the non-SSL case, 157 for SSL&lt;/li&gt;&lt;li&gt;Pauses greater than 0.2 seconds: 5 in the non-SSL case, 38 for SSL&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;This certainly bears further investigation in a following post, which I'll get to unles I get distracted by a bright, shiny object.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Findings for String Parameter Types&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The performance chart for the large string-based payload test is as follows:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkHcvRSITkI/AAAAAAAAARQ/hJ4t1ahmgQA/s1600-h/largestringperf.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SkHcvRSITkI/AAAAAAAAARQ/hJ4t1ahmgQA/s400/largestringperf.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5350800536944266818" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 291px; " /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;Seconds per web service call, large string-based payload, by Tcp window scale mod&lt;/i&gt;e&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;With the exception of streamed NetTcp, there's a slight performance gain seen in all of the bindings, ranging from about 15% - 25%, when larger Tcp window sizes are used. Overall, the results are the same as the findings of my last post: streamed netTcp is the worst-performing binding, followed by the two streamed BasicHttp bindings, followed by buffered BasicHttp with SSL, followed by the rest, with buffered NetTcp the best performing of the bunch.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;And the small string-based web service payload test gives similar results to the ones in my last post: streamed BasicHttp bindings perform worst due to the WCF bug that I talked about in my last post, buffered NetTcp performs best, and the rest are in the middle:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkHcvFuWrqI/AAAAAAAAARI/Bfsrv90AwU0/s1600-h/smallstringperf.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SkHcvFuWrqI/AAAAAAAAARI/Bfsrv90AwU0/s400/smallstringperf.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5350800533841424034" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 291px; " /&gt;&lt;/a&gt;&lt;i&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: normal; "&gt;&lt;i&gt;Seconds per web service call, small string-based payload, by Tcp window scale mod&lt;/i&gt;e&lt;/span&gt;&lt;/div&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: left; "&gt;In these tests the TcpWindow has no detectable effect on performance at all.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If any words of wisdom come out of these last two posts, it's that all bindings are not alike, and if you want your WCF application to perform well, you had better give careful attention to the bindings you use in your application.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-4077409116061626935?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='enclosure' type='video/mp4' href='http://www.blogger.com/video-play.mp4?contentId=e3091ba8c2e1330b&amp;type=video%2Fmp4' length='0'/><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/4077409116061626935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/06/effect-on-wcf-web-service-performance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4077409116061626935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4077409116061626935'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/06/effect-on-wcf-web-service-performance.html' title='Effect on WCF web service performance of the Tcp window size in high-latency Windows networks'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_-6lCnWdTHH4/SkHRdW2yW6I/AAAAAAAAAPo/05RNfijQTrI/s72-c/Katie.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-4219826749765002546</id><published>2009-05-24T11:39:00.000-07:00</published><updated>2009-05-26T18:35:40.197-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TCP'/><category scheme='http://www.blogger.com/atom/ns#' term='SSL'/><category scheme='http://www.blogger.com/atom/ns#' term='WCF'/><title type='text'>WCF Bug on W2K3 and XP: TCP session closes after every web service call when using HTTP transport with Streamed transfer mode</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShyX3-tXqdI/AAAAAAAAAPY/6-A3knNRQ20/s1600-h/secondspercallxplarge.jpg"&gt;&lt;/a&gt;While profiling a WCF-based application recently I uncovered a bug in WCF, in which &lt;span class="Apple-style-span" style="font-style: italic;"&gt;the WCF service host forcibly closes its TCP session with the client after each and every web service call. &lt;/span&gt;The client is helpless to prevent it, even if it keeps the client proxy open in the hope of reusing the session for subsequent calls. No exception happens when the client does make subsequent calls; instead the proxy silently negotiates a new TCP session and continues on its merry way. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A Microsoft representative that I talked to about this confirms that this is an issue in WCF services hosted on Windows 2003 and XP, if they use HTTP transport with transportMode "Streamed" or "StreamedRequest." The bug doesn't affect transportMode "StreamedResponse," and has been fixed on Vista, Windows 2008 and Windows 7.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This bug is potentially a big deal because, as I noted in my &lt;a href="http://computing-tombarreras.blogspot.com/2009/05/ssl-handshaking-overview.html"&gt;last post&lt;/a&gt;, initiating a new TCP session requires a synchronous round-trip to the server, which, thanks to this bug, becomes overhead added to each and every web service call. And if SSL is in use then at least one more synchronous round trip will be added to every call. These round trips are detrimental to performance, especially in high-latency environments.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:x-large;"&gt;Seeing the Bug in a Packet Trace&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The bug is very easy to see in a network packet trace. For these traces I'm using &lt;a href="http://www.wireshark.org/"&gt;Wireshark&lt;/a&gt;, though most any packet sniffer will do. See my &lt;a href="http://computing-tombarreras.blogspot.com/2009/05/ssl-handshaking-overview.html"&gt;last post&lt;/a&gt; for instructions on how to use Wireshark.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&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-size:large;"&gt;The Test Web Service&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The service I'm using for this test is simply this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm45dIkxkI/AAAAAAAAAMQ/FPMCN5YjDnY/s400/servicecontract.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339502130437080642" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 147px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/Shm45QuR8nI/AAAAAAAAAMY/KfASIm6M3MA/s1600-h/service.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/Shm45QuR8nI/AAAAAAAAAMY/KfASIm6M3MA/s400/service.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339502127105569394" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 125px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm45dIkxkI/AAAAAAAAAMQ/FPMCN5YjDnY/s1600-h/servicecontract.jpg"&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm45dIkxkI/AAAAAAAAAMQ/FPMCN5YjDnY/s1600-h/servicecontract.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;WCF service that demonstrates the bug&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You'll notice that this web service method does not have a &lt;a href="http://msdn.microsoft.com/en-us/library/system.io.stream.aspx"&gt;Stream&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx"&gt;Message &lt;/a&gt;or &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx"&gt;IXmlSerializable &lt;/a&gt;return type or parameter, which according to &lt;a href="http://msdn.microsoft.com/en-us/library/ms789010.aspx"&gt;this MSDN article&lt;/a&gt; is needed to make use of WCF streaming. This post therefore covers what happens to the performance of &lt;span class="Apple-style-span" style="font-style: italic; "&gt;other&lt;/span&gt; (non-streaming) web service methods that are part of a web service that has been configured to support streaming. An evaluation of how the bug affects web service methods that do stream will be the topic of another post, unless, to paraphrase &lt;a href="http://en.wikiquote.org/wiki/Shrek_2"&gt;Shrek&lt;/a&gt;, I change my mind, or forget.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Test Server&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;For the server I used a very unremarkable Console app as the WCF self-hosting service:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm56UaQ6LI/AAAAAAAAAMg/lqSu-MTvjOc/s1600-h/servicehost.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm56UaQ6LI/AAAAAAAAAMg/lqSu-MTvjOc/s400/servicehost.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339503244786854066" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 189px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Console app used as the WCF service host&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With the following basicHttpBinding endpoint:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/Shm6vkLQ9aI/AAAAAAAAAMo/cQEvbNtldY8/s1600-h/serviceconfig.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/Shm6vkLQ9aI/AAAAAAAAAMo/cQEvbNtldY8/s400/serviceconfig.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339504159551976866" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 55px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;WCF service host's App.config endpoint configuration&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;The Test Client&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The client just calls the web service twice:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnGV6HsrFI/AAAAAAAAAMw/7z5aXjt5TY0/s1600-h/twoclientcalls.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnGV6HsrFI/AAAAAAAAAMw/7z5aXjt5TY0/s400/twoclientcalls.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339516912905530450" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 140px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;WCF client code used for testing&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;with Streaming enabled:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShnHsIcRiyI/AAAAAAAAANI/-eMX-Q9S0Hg/s1600-h/clientconfig.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShnHsIcRiyI/AAAAAAAAANI/-eMX-Q9S0Hg/s400/clientconfig.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339518394218679074" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 49px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;WCF client binding specified in its App.config&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;The Bug Exposed&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The bug can be seen by comparing the network traffic produced by the calls shown above using an XP server, with the traffic produced by a Vista server:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnGV_Sp-HI/AAAAAAAAAM4/7qDuhrqz2w8/s1600-h/twostreamingcallstovista.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnGV_Sp-HI/AAAAAAAAAM4/7qDuhrqz2w8/s400/twostreamingcallstovista.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339516914293667954" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 97px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Packet trace showing multiple web service calls using the same client proxy, using Vista as the server - Click on the image to view it more clearly&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnGWGR4OuI/AAAAAAAAANA/GpyQdrWwpnM/s1600-h/twostreamingcallstoxp.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnGWGR4OuI/AAAAAAAAANA/GpyQdrWwpnM/s400/twostreamingcallstoxp.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339516916169456354" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 128px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Packet trace showing multiple web service calls using the same client proxy, using XP as the server  - Click on the image to view it more clearly&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These packet traces show that when XP is used as the WCF service host, the TCP connection is closed and re-opened between web service calls. This is verified by the fact that on XP each call is made using a different client port, while on Vista the same port is used for each call.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:x-large;"&gt;Evaluating the effect of the Bug&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to evaluate the effect that this bug has on WCF performance, I ran a set of tests, the results of which I'll describe below. The first test was simply to run the simple WCF service shown above using different binding configurations in a loop against XP and Vista, and to note the performance of each binding.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Test Bindings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;The server bindings I used for this initial test are these:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnJ72ZTeLI/AAAAAAAAANQ/tTc71ap1kv0/s1600-h/serverbindings.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnJ72ZTeLI/AAAAAAAAANQ/tTc71ap1kv0/s400/serverbindings.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339520863275546802" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 371px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;Server bindings tested for performance&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I tested custom bindings designed to simulate basicHttpBindings just to verify that the issue affects any http-based transport, and not just basicHttp, but I found that the timings for those bindings were identical to the timings for the basicHttpBindings. From here on out I'm dropping them from these results, to keep the clutter down.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&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-size:large;"&gt;The Test Client&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For the client I used a simple console app that calls the web service using each of the client bindings in a loop for 10 seconds, and counts the number of web service calls it's able to make:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnK3QJCYnI/AAAAAAAAANg/vSKBG5qOaYM/s1600-h/clientprogram1.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnK3QJCYnI/AAAAAAAAANg/vSKBG5qOaYM/s400/clientprogram1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339521883798921842" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 161px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnK3N733fI/AAAAAAAAANY/5r2txEWBUHc/s1600-h/clientprogram2.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/ShnK3N733fI/AAAAAAAAANY/5r2txEWBUHc/s400/clientprogram2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339521883206835698" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 274px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Client code used to test the performance of various WCF bindings&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Bug on Low Latency Networks&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are the results:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShmpvW288QI/AAAAAAAAAMI/GLDe8UmhSEc/s1600-h/callsperseclowlatencysmallpayload.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShmpvW288QI/AAAAAAAAAMI/GLDe8UmhSEc/s400/callsperseclowlatencysmallpayload.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339485464279445762" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 176px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Web service calls per second on low latency network, using a small web service payload&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This test was conducted on my home network using two computers, an XP machine and a Vista machine. They're connected by an 8011.n wireless network that has about 1 ms round-trip latency.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The first thing that stands out about the results is the remarkable performance of buffered NetTcp, which was able to move twice as many calls per second as the other bindings. The next thing that stands out is the fact that while all the other bindings perform about the same on Vista, on XP the basicHttp-streamed binding is about 25% slower than the others, and basicHttps-streamed is about 50% slower than the others. So even in this low latency test, the overhead of setting up new TCP and SSL sessions for every call has a measurable impact on performance.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, even though the graphs above represent two different machines, the fact that the number of calls each machine is able to process per second is approximately the same gives me some confidence that I'll be able to compare absolute call times between them in the analyses that follow.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Bug on High Latency Networks&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The bug has a measurable effect even in low-latency networks, but the performance numbers shown above are still pretty good. An end-user is not likely to notice the difference between an application that's making 50 web service calls per second v. one that's making 250 calls per second. What is of more interest is how the bug behaves in high-latency networks. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To simulate different network latency times, I used the &lt;a href="http://wanem.sourceforge.net/"&gt;WANEmulator&lt;/a&gt;, a marvelous tool that literally takes minutes to set up, and which makes an excellent Christmas gift, especially since it's free. Running the same tests with 50ms, 100ms and 200ms round-trip times produced the following results:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnS3BEIkwI/AAAAAAAAANo/Oi2ARWmo1xI/s1600-h/secondspercallxp.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShnS3BEIkwI/AAAAAAAAANo/Oi2ARWmo1xI/s400/secondspercallxp.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339530675844846338" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 306px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;Seconds per basicHttp web service call on Windows XP&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnS3d-Vp5I/AAAAAAAAANw/Jt1nra5I4P0/s1600-h/secondspercallvista.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnS3d-Vp5I/AAAAAAAAANw/Jt1nra5I4P0/s400/secondspercallvista.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339530683605165970" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 300px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Seconds per basicHttp web service call on Vista&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The results are not surprising. With 200ms round-trip times, streaming added 200ms to the average web service call time, due to the need to make an extra round trip to establish the TCP session. And SSL adds another 200ms to the call for establishing the SSL session. Though it's not readily visible in the packet traces I've got right now, in other traces I have seen that WCF is able to establish SSL sessions in a single round-trip, so again the result above is not surprising.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It's good to see in the results above that on Vista the problem is really fixed, that all four bindings take the same amount of time, and that the amount of time time they take is the faster of the times taken on XP (e.g. 0.4 seconds per call at 200ms).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The bad news in the results above is that latency has a dramatic impact on even the best performance numbers above - from lightning-fast at 1ms latency to 0.4 seconds per call at 200 ms latency. The reason for this is&lt;span class="Apple-style-span" style="font-style: italic;"&gt; not&lt;/span&gt; entirely obvious. Remember that at in the tests above, we are averaging the call time between many calls, and (except for streamed bindings on XP where the bug is restarting the TCP session every time) we are reusing the TCP and the SSL sessions between calls, so the time needed to establish those sessions should hardly be visible in these results. Since my test web service is a two-way call (it doesn't have the &lt;a href="http://msdn.microsoft.com/en-us/library/ms733035.aspx"&gt;IsOneWay&lt;/a&gt; operation contract attribute), each call will result in at least one synchronous round trip, but the source of any additional overhead is not obvious.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The further bad news is that when the bug is present, web service calls are again 25% slower in the streaming case, and 50% slower in the streaming+ssl case, than they should be.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Another interesting result appears if I add back the other bindings to the chart:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnX9OTOX-I/AAAAAAAAAN4/70zD_nz6XAQ/s1600-h/secondspercallxpall.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnX9OTOX-I/AAAAAAAAAN4/70zD_nz6XAQ/s400/secondspercallxpall.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339536280035155938" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 279px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;Seconds per call of various bindings on XP, with various network latency figures&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While WS2007 and streamed  NetTcp have nearly identical results as buffered basicHttp, buffered NetTcp again stands out as being twice as fast as all the rest. In fact, its call times are almost exactly equal the round-trip time itself, which is the theoretical minimum.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Bug with Large Web Service Payloads&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Again, I'm not going to analyze the bug when streaming-based parameters are in use, for the very good reason that I don't feel like it right now, but even an unstreamed web service method can include a larger payload than the "hi mom" text I used above. To see the effect of the bug on those types of methods, I changed the client to send a gob of text that's about 277KB in length. To prevent anyone from compressing it, I serialized something that's already been compressed, a JPEG of my daughter:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShncdxKdt_I/AAAAAAAAAOA/FEuHVK06U6o/s1600-h/Katie.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/ShncdxKdt_I/AAAAAAAAAOA/FEuHVK06U6o/s400/Katie.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339541237195978738" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 238px; height: 400px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;My daughter Kaitlin&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Like so:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShndnrFgV8I/AAAAAAAAAOI/VfMG1xUfFQ8/s1600-h/clientprogram3.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShndnrFgV8I/AAAAAAAAAOI/VfMG1xUfFQ8/s400/clientprogram3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339542506874886082" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 186px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShneBbDh6vI/AAAAAAAAAOQ/C8DOmnzt1bY/s1600-h/clientprogram4.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShneBbDh6vI/AAAAAAAAAOQ/C8DOmnzt1bY/s400/clientprogram4.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339542949248232178" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 271px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Client program that sends a picture of Kaitlin to the server in a loop, using different bindings, and times the result&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Naturally I had to increase some of the max size parameters in the client and server bindings to allow for larger messages:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/Shn9NjoNBWI/AAAAAAAAAPQ/z9DO1WiVj0g/s1600-h/serverbindings2.jpg"&gt;&lt;img src="http://3.bp.blogspot.com/_-6lCnWdTHH4/Shn9NjoNBWI/AAAAAAAAAPQ/z9DO1WiVj0g/s400/serverbindings2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339577242568426850" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 195px; " /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Server bindings that allow for larger message sizes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shnfoi5PEvI/AAAAAAAAAOg/K4J6DIogzLI/s1600-h/clientbindings.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shnfoi5PEvI/AAAAAAAAAOg/K4J6DIogzLI/s400/clientbindings.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339544720879063794" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 206px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;div style="text-align: center;"&gt;Client bindings that allow for larger message sizes&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the client bindings above I collapsed some of the duplicate settings to save space.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Bug on a Low Latency Network with a Large Web Service Payload &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The results are as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/Shnhbn4a5YI/AAAAAAAAAOo/L_K5m86KcEA/s1600-h/callsperseclowlatencylargepayload.jpg"&gt;&lt;img src="http://4.bp.blogspot.com/_-6lCnWdTHH4/Shnhbn4a5YI/AAAAAAAAAOo/L_K5m86KcEA/s400/callsperseclowlatencylargepayload.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339546697902777730" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 175px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;div style="text-align: center;"&gt;Web service calls per second on low latency network, using a large web service payload&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The graph has the same general shape as it did with a small payload, though the absolute numbers are much different - 7 or 8 calls per second at best, compared to 250 calls per second with the small payload. With a payload this large network bandwidth is no doubt affecting these numbers, but since bandwidth is fixed throughout these tests, they should work fine for determining the relative effect of latency on WCF.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Again buffered NetTcp is the runaway performance winner, but this time streamed basicHttp performs about as well as the rest, and we have a new loser: streamed NetTcp.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the bug is not measurable with large payloads in low latency environments. This makes good sense, because each web service call is taking so much more time just to transfer its payload that the TCP and SSL session initiation time is small by comparison.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;The Bug on High Latency Networks with Large Web Service Payloads&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Logically, in high-latency environments the TCP and SSL session initiation time should continue to be overwhelmed by the sheer amount of time taken to deliver the payload, but let's see what the testing shows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShyX3-tXqdI/AAAAAAAAAPY/6-A3knNRQ20/s1600-h/secondspercallxplarge.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ShyX3-tXqdI/AAAAAAAAAPY/6-A3knNRQ20/s400/secondspercallxplarge.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5340310246136457682" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 292px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;Seconds per basicHttp web service call on Windows XP with a large web service payload&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shnm8bjY0wI/AAAAAAAAAO4/vuJauog9B04/s1600-h/secondspercallvistalarge.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_-6lCnWdTHH4/Shnm8bjY0wI/AAAAAAAAAO4/vuJauog9B04/s400/secondspercallvistalarge.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339552759087158018" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 292px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;div style="text-align: center;"&gt;Seconds per basicHttp web service call on Vista, with a large web service payload&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To our shock and horror, we see that the bug appears to affect performance in the same proportion as in the small payload case, only now instead of increasing call times from 0.4 seconds per call to 0.8 seconds per call, it's increasing call times from 2 seconds to 6. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The good news (if anything about the above charts can be called "good") is that the bug remains more or less fixed on Vista, where call times are uniformly close to the best call times on XP, roughly 3 to 4 seconds per call. The Vista results appear to show that there is some additional overhead involved in streaming large payloads however, which amounts to about an additional 1 second per call in the 200ms latency case.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But even if we assume that, apart from the bug, there's 1 sec. worth of "normal" overhead involved in streaming large payloads in the 200ms latency case, that still leaves 1-2 seconds of overhead that we can only attribute to the bug. It would appear that closing and re-opening the TCP session carries some additional penalty beyond the round-trip TCP session establishment time. Something called &lt;a href="http://www.potaroo.net/ispcol/2000-09/2000-09-latency.html"&gt;"slow start" TCP session tuning&lt;/a&gt; may be the culprit (sure sounds like it, don't ya think?), but to date I haven't proven it, mainly due to laziness, since I have the packet traces in which must lie the smoking gun.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Performance of Other Bindings with Large Payloads&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Though it has nothing to do with the stated purpose of this post, it's fun to add back the other binding types to the chart above:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnvS_yrYuI/AAAAAAAAAPA/F5KDrM4judw/s1600-h/secondspercallvistalargeall.jpg"&gt;&lt;img src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ShnvS_yrYuI/AAAAAAAAAPA/F5KDrM4judw/s400/secondspercallvistalargeall.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5339561942865109730" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 311px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;div style="text-align: center;"&gt;Seconds per call of various bindings on Vista, with various network latency figures, using a large web service method payload&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While WS2007 performs about as well as the best of the basicHttp methods, buffered NetTcp is again the speed king, coming in at a good 1/3 faster than the best of the rest. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But what can we say about streamed NetTcp? It's taking 15 seconds per call in the 200 ms latency case, a good 4 times slower than all the rest! Only Dr. Seuss seems adequate: &lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: left;"&gt;This mess is so big,&lt;/div&gt;&lt;div style="text-align: left;"&gt;and so deep,&lt;/div&gt;&lt;div style="text-align: left;"&gt;and so tall,&lt;/div&gt;&lt;div style="text-align: left;"&gt;we cannot clean it up.&lt;/div&gt;&lt;div style="text-align: left;"&gt;There is no way at all&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Granted, I'm not making any attempt to tune these bindings; other than max message size settings I'm using defaults. But note that all these bindings are blindingly fast in low latency environments. If nothing else this shows the danger of failing to take latency into account when testing your WCF services.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And that would seem like a good stopping point for this particular post. This exercise produced many more fascinating results which the margin of this blog is too small to contain, but that will have to wait for another day. Unless I change my mind, or forget.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&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-size:large;"&gt;Appendix - the Data&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The industrious among you can reproduce the above graphs and many others using the following data.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Vista Data - Small Payload&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="0"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Call/sec&lt;/td&gt;&lt;td&gt;1ms&lt;/td&gt;&lt;td&gt;50ms&lt;/td&gt;&lt;td&gt;100ms&lt;/td&gt;&lt;td&gt;200ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Buffered&lt;/td&gt;&lt;td&gt;258&lt;/td&gt;&lt;td&gt;18.04&lt;/td&gt;&lt;td&gt;9.62&lt;/td&gt;&lt;td&gt;4.8&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Buffered&lt;/td&gt;&lt;td&gt;125&lt;/td&gt;&lt;td&gt;9.26&lt;/td&gt;&lt;td&gt;4.74&lt;/td&gt;&lt;td&gt;2.48&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WS2007&lt;/td&gt;&lt;td&gt;117&lt;/td&gt;&lt;td&gt;9.52&lt;/td&gt;&lt;td&gt;4.72&lt;/td&gt;&lt;td&gt;2.48&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Buffered&lt;/td&gt;&lt;td&gt;111&lt;/td&gt;&lt;td&gt;9.34&lt;/td&gt;&lt;td&gt;4.67&lt;/td&gt;&lt;td&gt;2.48&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Streamed&lt;/td&gt;&lt;td&gt;111&lt;/td&gt;&lt;td&gt;8.58&lt;/td&gt;&lt;td&gt;4.44&lt;/td&gt;&lt;td&gt;2.46&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Streamed&lt;/td&gt;&lt;td&gt;113&lt;/td&gt;&lt;td&gt;8.98&lt;/td&gt;&lt;td&gt;4.62&lt;/td&gt;&lt;td&gt;2.48&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Streamed&lt;/td&gt;&lt;td&gt;103&lt;/td&gt;&lt;td&gt;8.98&lt;/td&gt;&lt;td&gt;4.72&lt;/td&gt;&lt;td&gt;2.36&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Vista Data - Large Payload&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="0"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Calls/sec&lt;/td&gt;&lt;td&gt;1ms&lt;/td&gt;&lt;td&gt;50ms&lt;/td&gt;&lt;td&gt;100ms&lt;/td&gt;&lt;td&gt;200ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Buffered&lt;/td&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;1.844444&lt;/td&gt;&lt;td&gt;0.9166667&lt;/td&gt;&lt;td&gt;0.5083333&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WS2007&lt;/td&gt;&lt;td&gt;3.7&lt;/td&gt;&lt;td&gt;1.147222&lt;/td&gt;&lt;td&gt;0.5972222&lt;/td&gt;&lt;td&gt;0.3111111&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Buffered&lt;/td&gt;&lt;td&gt;3.74&lt;/td&gt;&lt;td&gt;1.144444&lt;/td&gt;&lt;td&gt;0.605555&lt;/td&gt;&lt;td&gt;0.3194444&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Buffered&lt;/td&gt;&lt;td&gt;3.78&lt;/td&gt;&lt;td&gt;1.088889&lt;/td&gt;&lt;td&gt;0.5555556&lt;/td&gt;&lt;td&gt;0.3083333&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Streamed&lt;/td&gt;&lt;td&gt;3.5&lt;/td&gt;&lt;td&gt;0.775&lt;/td&gt;&lt;td&gt;0.4222222&lt;/td&gt;&lt;td&gt;0.2444444&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Streamed&lt;/td&gt;&lt;td&gt;3.4&lt;/td&gt;&lt;td&gt;0.8277778&lt;/td&gt;&lt;td&gt;0.44722222&lt;/td&gt;&lt;td&gt;0.24166667&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Streamed&lt;/td&gt;&lt;td&gt;1.88&lt;/td&gt;&lt;td&gt;0.2361111&lt;/td&gt;&lt;td&gt;0.1222222&lt;/td&gt;&lt;td&gt;0.06944445&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;XP - Small payload&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="0"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Calls/sec&lt;/td&gt;&lt;td&gt;1ms&lt;/td&gt;&lt;td&gt;50ms&lt;/td&gt;&lt;td&gt;100ms&lt;/td&gt;&lt;td&gt;200ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Buffered&lt;/td&gt;&lt;td&gt;250&lt;/td&gt;&lt;td&gt;18.13333&lt;/td&gt;&lt;td&gt;9.48&lt;/td&gt;&lt;td&gt;4.86&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Buffered&lt;/td&gt;&lt;td&gt;131&lt;/td&gt;&lt;td&gt;9.766666&lt;/td&gt;&lt;td&gt;4.8&lt;/td&gt;&lt;td&gt;2.5&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WS2007&lt;/td&gt;&lt;td&gt;120&lt;/td&gt;&lt;td&gt;9.5&lt;/td&gt;&lt;td&gt;4.88&lt;/td&gt;&lt;td&gt;2.46&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Buffered&lt;/td&gt;&lt;td&gt;113&lt;/td&gt;&lt;td&gt;9.233334&lt;/td&gt;&lt;td&gt;4.86&lt;/td&gt;&lt;td&gt;2.46&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Streamed&lt;/td&gt;&lt;td&gt;110&lt;/td&gt;&lt;td&gt;8.933333&lt;/td&gt;&lt;td&gt;4.66&lt;/td&gt;&lt;td&gt;2.48&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Streamed&lt;/td&gt;&lt;td&gt;83&lt;/td&gt;&lt;td&gt;5.6&lt;/td&gt;&lt;td&gt;3.18&lt;/td&gt;&lt;td&gt;1.68&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Streamed&lt;/td&gt;&lt;td&gt;51&lt;/td&gt;&lt;td&gt;4.533333&lt;/td&gt;&lt;td&gt;2.38&lt;/td&gt;&lt;td&gt;1.28&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;XP - Large Payload&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="0"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Calls / sec&lt;/td&gt;&lt;td&gt;1ms&lt;/td&gt;&lt;td&gt;50ms&lt;/td&gt;&lt;td&gt;100ms&lt;/td&gt;&lt;td&gt;200ms&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Buffered&lt;/td&gt;&lt;td&gt;7.16&lt;/td&gt;&lt;td&gt;2.072222&lt;/td&gt;&lt;td&gt;1.125&lt;/td&gt;&lt;td&gt;0.6222222&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;WS2007&lt;/td&gt;&lt;td&gt;3.38&lt;/td&gt;&lt;td&gt;1.352778&lt;/td&gt;&lt;td&gt;0.7555556&lt;/td&gt;&lt;td&gt;0.3833333&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Buffered&lt;/td&gt;&lt;td&gt;3.9&lt;/td&gt;&lt;td&gt;1.361111&lt;/td&gt;&lt;td&gt;0.7416667&lt;/td&gt;&lt;td&gt;0.4027778&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Buffered&lt;/td&gt;&lt;td&gt;3.42&lt;/td&gt;&lt;td&gt;1.005556&lt;/td&gt;&lt;td&gt;0.5388889&lt;/td&gt;&lt;td&gt;0.2916667&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttp Streamed&lt;/td&gt;&lt;td&gt;3.18&lt;/td&gt;&lt;td&gt;0.6444445&lt;/td&gt;&lt;td&gt;0.3277778&lt;/td&gt;&lt;td&gt;0.1861111&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;BasicHttps Streamed&lt;/td&gt;&lt;td&gt;3.42&lt;/td&gt;&lt;td&gt;0.5972222&lt;/td&gt;&lt;td&gt;0.3166667&lt;/td&gt;&lt;td&gt;0.1666667&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;NetTcp Streamed&lt;/td&gt;&lt;td&gt;1.74&lt;/td&gt;&lt;td&gt;0.233333333&lt;/td&gt;&lt;td&gt;0.12777778&lt;/td&gt;&lt;td&gt;0.06666667&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-4219826749765002546?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/4219826749765002546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/05/wcf-bug-on-w2k3-and-xp-tcp-session.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4219826749765002546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4219826749765002546'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/05/wcf-bug-on-w2k3-and-xp-tcp-session.html' title='WCF Bug on W2K3 and XP: TCP session closes after every web service call when using HTTP transport with Streamed transfer mode'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_-6lCnWdTHH4/Shm45dIkxkI/AAAAAAAAAMQ/FPMCN5YjDnY/s72-c/servicecontract.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-3606620781001640114</id><published>2009-05-10T19:10:00.000-07:00</published><updated>2009-05-11T22:11:30.229-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SSL'/><category scheme='http://www.blogger.com/atom/ns#' term='SSL 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='TLS 1.0'/><title type='text'>SSL Handshaking Overview</title><content type='html'>The goal of this post is to review what happens at the TCP/IP level when an SSL connection is initiated, paying particular attention to the parts of the handshake protocol that are synchronous, i.e., that result in the client or the server waiting for a response from the other before proceeding. Most of this post comes from the SSL 3.0 Specification listed on &lt;a href="http://www.lincoln.edu/math/rmyrick/ComputerNetworks/InetReference/ssl-draft/3-SPEC.HTM"&gt;this web site&lt;/a&gt; and the TLS 1.0 Specification listed &lt;a href="http://www.ietf.org/rfc/rfc2246.txt"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;"&gt;Initiating a TCP Session&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a client such as a web browser first contacts a web site via SSL, the first thing that happens is a new TCP/IP session is initiated between the selected client port and the port handling SSL connections on the server, usually port 443:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKV5flFUI/AAAAAAAAAKg/Wz4rtssS13o/s1600-h/inittcpsession.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 197px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKV5flFUI/AAAAAAAAAKg/Wz4rtssS13o/s400/inittcpsession.jpg" alt="" id="BLOGGER_PHOTO_ID_5334384392458802498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is a diagram of the standard 3-way handshake that initiates a TCP connection.&lt;br /&gt;&lt;br /&gt;The TCP protocol provides reliable packet delivery by embedding a sequence number in every packet. Whenever an endpoint receives a TCP packet it responds with an acknowledgment (abbreviated as an “&lt;span style="font-weight: bold;"&gt;ACK&lt;/span&gt;”)  indicating the highest sequence number it has successfully received. If the sender doesn’t receive and ACK for a packet it’s sent within a certain time period, it assumes the packet was lost, and re-sends it.&lt;br /&gt;&lt;br /&gt;When an HTTPS request is sent to a server, the first thing that happens is that a new TCP/IP connection is established with the port the server uses for SSL connections, usually port 443.&lt;br /&gt;&lt;br /&gt;The client issues a synchronization request (abbreviated as “&lt;span style="font-weight: bold;"&gt;SYN&lt;/span&gt;”), in which it indicates the client port number for the conversation, and with the initial sequence number for packets originating from the client.&lt;br /&gt;&lt;br /&gt;The server responds by ACKing the client’s request, and with a SYN of its own, which contains its initial sequence number for packets originating from the server.&lt;br /&gt;&lt;br /&gt;In the diagram, packets originating from the client are shown in blue, and packets originating from the server are in green. Dark-colored lines indicate synchronous conversations. E.g., the client sends its initial SYN and waits for the server to respond. The server responds, and the synchronous part of the conversation is completed. The client ACKs the server’s response, and then continues immediately with the next conversation, which is the client/server hello:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;"&gt;The Client and Server Hellos&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKV3XtesI/AAAAAAAAAKo/lAxdcIQwMCc/s1600-h/clientserverhello.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 226px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKV3XtesI/AAAAAAAAAKo/lAxdcIQwMCc/s400/clientserverhello.jpg" alt="" id="BLOGGER_PHOTO_ID_5334384391888927426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this diagram the client begins by sending the SSL &lt;span style="font-weight: bold;"&gt;Client Hello&lt;/span&gt; message, which contains, among other things, the highest version of SSL supported by the client, the list of encryption algorithms supported by the client, and a random number that will be used as a seed value for generating the SSL &lt;span style="font-weight: bold;"&gt;master secret&lt;/span&gt; encryption key.&lt;br /&gt;&lt;br /&gt;This is a good time to note that SSL is based on both &lt;span style="font-weight: bold;"&gt;PKI encryption&lt;/span&gt; (public-key infrastructure) and on &lt;span style="font-weight: bold;"&gt;symmetric encryption&lt;/span&gt;. PKI encryption is based on a pair of keys, a public key and a private key. The properties of PKI encryption that make it so useful are these:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Anything encrypted with the public key can only be decrypted with the private key.&lt;/li&gt;&lt;li&gt; Anything encrypted with the private key can only be decrypted with the public key.&lt;/li&gt;&lt;/ul&gt;The server can therefore broadcast its public key to the world, and the client can use it to encrypt its messages without fear that anyone other than the holder of the private key can decrypt it. But PKI encryption is slow, so SSL uses it only to encrypt a seed value that is used to generate a symmetric key, which is used by the client and server to encrypt the rest of the conversation. Symmetric key encryption algorithms use a single key for both encryption and decryption. These algorithms are faster than PKI, but presuppose that the participants in the conversation have a secure way to exchange the encryption key.&lt;br /&gt;&lt;br /&gt;In SSL, the conversation’s symmetric key is called the “master secret.” The key itself is not sent over the wire. Instead, three seed values are sent across the wire that the client and server can use to generate the actual symmetric key. The seed values include a random number generated on the client and sent to the server in the clear (unencrypted), a random number generated on the server and sent to the client in the clear, and another random number generated on the client and sent to the server encrypted via PKI.&lt;br /&gt;&lt;br /&gt;Once the client sends the Client Hello it must wait for the server to respond with a set of messages that begin with a &lt;span style="font-weight: bold;"&gt;Server Hello&lt;/span&gt; message and end with a &lt;span style="font-weight: bold;"&gt;Server Hello Done&lt;/span&gt;. The messages sent by the server in between the Server Hello and the Server Hello Done depend on whether the server authenticates itself using digital certificates, and whether it requires clients to authenticate themselves with digitial certificates.&lt;br /&gt;&lt;br /&gt;The diagram shows the most common case, in which the server authenticates itself to the client with a digital certificate, but does not require the client to authenticate itself.&lt;br /&gt;&lt;br /&gt;In that scenario, the server selects the strongest encryption algorithm supported by both client and server, and returns its selection in the Server Hello, along with a random number generated on the server for use in creating the symmetric encryption key. It sends its digital certificate in a &lt;span style="font-weight: bold;"&gt;Server Certificate &lt;/span&gt; message, and then sends a Server Hello Done message.&lt;br /&gt;&lt;br /&gt;As with the previous diagram, the synchronous part of the conversation uses dark colors. The ACKs are in lighter colors and are not synchronous. Which is to say, the client sends the Client Hello, and then waits for the stream of messages ending with the Server Hello Done. Neither side waits for the ACKs.&lt;br /&gt;&lt;br /&gt;The client is now ready to send the information the server will need to generate the symmetric encryption key, and to instruct the server to switch to the chosen symmetric encryption algorithm:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;"&gt;The Client and Server Key Exchange, Change Cipher Specs and Finished Messages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKWDCc-8I/AAAAAAAAAKw/KcbHuMN8Lmk/s1600-h/clientserverkeyexchange.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 220px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKWDCc-8I/AAAAAAAAAKw/KcbHuMN8Lmk/s400/clientserverkeyexchange.jpg" alt="" id="BLOGGER_PHOTO_ID_5334384395020991426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;In this diagram the client generates the information necessary for the client and server to generate the “master secret,” which is the symmetric encryption key. The exact information sent differs based on the encryption algorithm used. The client sends this in an SSL &lt;span style="font-weight: bold;"&gt;Client Key Exchange&lt;/span&gt; message.&lt;br /&gt;&lt;br /&gt;The client then sends a &lt;span style="font-weight: bold;"&gt;Change Cipher Specs&lt;/span&gt; message, which is just a flag message that contains no data payload, and then a &lt;span style="font-weight: bold;"&gt;Finished &lt;/span&gt;message, which is the first message encrypted using the symmetric key. The content of the message is the entire handshake conversation up to the Change Cipher Specs message, which the recipient will decode to verify that encryption is working properly.&lt;br /&gt;&lt;br /&gt;The server must wait to receive the client key information before proceeding with its part of the conversation, but the client doesn’t have to wait for the server to do so before it starts to send encrypted content under the session, so the synchronous part of the SSL setup has effectively concluded.&lt;br /&gt;&lt;br /&gt;The server does reciprocate with its own Change Cipher Specs and Finished message however, which again contains an encrypted copy of the entire handshaking exchange between itself and the client. The client is also required to decrypt the Finished message payload and verify that encryption is working properly.&lt;br /&gt;&lt;br /&gt;At this point the SSL connection, and the client and server may exchange encrypted content.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left; font-weight: bold;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold;font-size:130%;"&gt;Viewing the Packets in Wireshark&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All this becomes more concrete when the packets are viewed in a packet sniffer such as &lt;a href="http://www.wireshark.org/"&gt;Wireshark&lt;/a&gt;. Wireshark is very easy to use. Just download, install and run the application, and select Capture\Interfaces... in order to instruct Wireshark to start capturing packets on one of your network devices. If several devices are listed and you're not certain which to capture, just leave the dialog open for moment while you browse the Internet. The number in the "Packets" column in the dialog will increase on the network device being used by the browser.&lt;br /&gt;&lt;br /&gt;Next, find a web site that uses HTTPS, and load a web page from that site in your browser. You'll want to filter out all the network traffic except packets that are going to or coming from that site. You should be able to figure out the IP address of the site you're connecting to by viewing the packet stream in Wireshark as you refresh the browser. In my case I'm using a site with IP address 72.21.210.250. Once you've figured that out, add a filter to Wireshark Filter text box of this form: ip.dst == 72.21.210.250 or ip.src == 72.21.210.250.&lt;br /&gt;&lt;br /&gt;To get a clear picture of an entire SSL session, its best to wait a few minutes until the server you've connected to terminates your TCP connection. You'll see that happen in Wireshark when the server sends a TCP "FIN" message to your machine, which Wireshark highlights in dark gray by default. Then select Capture\Restart in Wireshark, and refresh the HTTPS page in your browser. You'll see something like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SgeSgYfZZuI/AAAAAAAAAK4/Q8noVa05l5c/s1600-h/wireshark1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SgeSgYfZZuI/AAAAAAAAAK4/Q8noVa05l5c/s400/wireshark1.jpg" alt="" id="BLOGGER_PHOTO_ID_5334393368671250146" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-decoration: underline;"&gt;Initiating the TCP Session&lt;/div&gt;&lt;br /&gt;The first message packet is the client's TCP SYN, requesting a new session containing the client port, 51805, and the starting packet sequence number, zero. The server ACKs the client's SYN and responds with a SYN of its own in the next message:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SgeTc1VEMHI/AAAAAAAAALA/jQIVgSF9KK8/s1600-h/wireshark2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SgeTc1VEMHI/AAAAAAAAALA/jQIVgSF9KK8/s400/wireshark2.jpg" alt="" id="BLOGGER_PHOTO_ID_5334394407204696178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Wireshark helpfully colors the two SYN packets in dark gray to highlight the fact that they represent the beginning of a new TCP session, and includes a "SEQ/ACK" analysis feature in its Packet Details pane that shows that the ACK in this packet is acknowledging receipt of the packet sent in frame 5 above.&lt;br /&gt;&lt;br /&gt;At this point we have a valid TCP session. The client ACKs the receipt of the server SYN, and then immediately proceeds to the Client Hello:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-decoration: underline;"&gt;Client and Server Hellos&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SgeWhMtjyWI/AAAAAAAAALI/-eSS9o3_gsw/s1600-h/wireshark3.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SgeWhMtjyWI/AAAAAAAAALI/-eSS9o3_gsw/s400/wireshark3.jpg" alt="" id="BLOGGER_PHOTO_ID_5334397780735805794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Wireshark notes that this is a TLS 1.0 (Transport Layer Security) message by identifying the protocol as TLSv1. &lt;a href="http://www.ietf.org/rfc/rfc2246.txt"&gt;TLS 1.0&lt;/a&gt; is basically a newer variant of SSL 3.0. The aspects of the handshaking protocols that I'm reviewing in this blog post used by the two protocols are the same, with one exception that I will note below.&lt;br /&gt;&lt;br /&gt;The server responds with two packets. The first is this:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SgebTQkQH9I/AAAAAAAAALQ/0tnUzezZ2Eg/s1600-h/wireshark4.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SgebTQkQH9I/AAAAAAAAALQ/0tnUzezZ2Eg/s400/wireshark4.jpg" alt="" id="BLOGGER_PHOTO_ID_5334403038810480594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Wireshark flags this as a "TCP segment of a reassembled PDU" (Protocol Data Unit). This is just a way of saying that a single higher-level protocol's "data unit" (a TLSv1 record in this case) has been broken up into two TCP packets for transmission.&lt;br /&gt;&lt;br /&gt;Expanding the Transmission Control Protocol node in the Packet Details pane, we can also see that this packet contains an ACK for the packet the client last sent.&lt;br /&gt;&lt;br /&gt;Moving on to frame 10 we can see that the server has packaged three SSL messages into a single data unit: a Server Hello, the Certificate, and the Server Hello Done:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SgedQbPEPoI/AAAAAAAAALY/2aSwqGYDILY/s1600-h/wireshark5.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SgedQbPEPoI/AAAAAAAAALY/2aSwqGYDILY/s400/wireshark5.jpg" alt="" id="BLOGGER_PHOTO_ID_5334405189158059650" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the Packet Details pane, Wireshark helpfully tells us that this single TLSv1 data unit has been reassembled from two TCP packets, which are shown in frames 9 and 10. Looking at the Secure Socket Layer info in the packet, we see the three messages. If we then expand the Server Hello details, we can see that the server selected the RSA PKI algorithm and the RC4 symmetric encryption algorithm using a 128-bit key, and the MD5 algorithm for hashing:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgefG0uV9KI/AAAAAAAAALg/3DzY0WoGIoI/s1600-h/wireshark6.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SgefG0uV9KI/AAAAAAAAALg/3DzY0WoGIoI/s400/wireshark6.jpg" alt="" id="BLOGGER_PHOTO_ID_5334407223224693922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-decoration: underline;"&gt;Client and Server Key Exchanges&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In frame 11 the client ACKs the server hello messages, and in frame 12 it immediately proceeds to the Client Key Exchange, Change Cipher Specs, and Finished message (which Wireshark calls an "Encrypted Handshake Method"), all of which are contained in a single TCP packet:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sgeh4O-FdgI/AAAAAAAAALo/VmSOSFPP9EM/s1600-h/wireshark7.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sgeh4O-FdgI/AAAAAAAAALo/VmSOSFPP9EM/s400/wireshark7.jpg" alt="" id="BLOGGER_PHOTO_ID_5334410271106889218" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Frame 13 is a server ACK, and in frame 14 we get the server's Change Cipher Specs and Finished messages:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/Sgeh4DRmr7I/AAAAAAAAALw/xQCoxo76Ss8/s1600-h/wireshark8.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 241px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/Sgeh4DRmr7I/AAAAAAAAALw/xQCoxo76Ss8/s400/wireshark8.jpg" alt="" id="BLOGGER_PHOTO_ID_5334410267967532978" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;And in Frame 15 we see the start of the actual SSL-encrypted content of the web page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;"&gt;Another Synchronous Handshake in TLS 1.0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One interesting thing to note about these Wireshark results is that, even though the client is supposed to be able to begin sending data as soon as it completes its client Finished message, in the results above it appears to wait until the server completes its server Finished message.&lt;br /&gt;&lt;br /&gt;This appears to be the only difference that we have encountered in this post between the SSL 3.0 spec and the TLS 1.0 spec. The SSL 3.0 spec contains the phrase "No acknowledgment of the &lt;b&gt;finished&lt;/b&gt; message is required" in its description of the client Finished message. That phrase has been removed from the TLS 1.0 spec, which is otherwise in many places a word-for-word copy of the SSL 3.0 spec. Also the flow diagram used by TLS 1.0 has been changed to make the client and server key exchange conversations synchronous.&lt;br /&gt;&lt;br /&gt;Therefore it would appear that for TLS 1.0 the key exchange diagram should look like this:&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SgkEkv_mS_I/AAAAAAAAAMA/Be-vJYfUkfI/s1600-h/clientserverkeyexchangetls1.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 224px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SgkEkv_mS_I/AAAAAAAAAMA/Be-vJYfUkfI/s400/clientserverkeyexchangetls1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5334800263002082290" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;to reflect the fact that the key exchange messages have been made synchronous in the newer protocol.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-3606620781001640114?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/3606620781001640114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/05/ssl-handshaking-overview.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/3606620781001640114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/3606620781001640114'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/05/ssl-handshaking-overview.html' title='SSL Handshaking Overview'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_-6lCnWdTHH4/SgeKV5flFUI/AAAAAAAAAKg/Wz4rtssS13o/s72-c/inittcpsession.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-2928754825036574264</id><published>2009-04-30T21:33:00.000-07:00</published><updated>2009-05-04T23:15:46.318-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Decorator Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='architectural patterns'/><title type='text'>Tom's Patterns Cheat Sheet , Part 6 - The Decorator Pattern</title><content type='html'>This post is based mainly off of the GoF Patterns Bible, &lt;a href="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1241498739&amp;amp;sr=8-1"&gt;Design Patterns: Elements of Reusable Object-Oriented Software&lt;/a&gt;. The basic Decorator Pattern is this:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sf_FfRY8-4I/AAAAAAAAAKA/e-Mon8MTgUU/s1600-h/decorator-basic.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 143px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sf_FfRY8-4I/AAAAAAAAAKA/e-Mon8MTgUU/s400/decorator-basic.jpg" alt="" id="BLOGGER_PHOTO_ID_5332197624864635778" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Basic Decorator Pattern&lt;/span&gt;&lt;br /&gt;(&lt;span style="font-style: italic;"&gt;Click on the diagram to open in a separate window)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;The name of the pattern is very descriptive. It involves a main class that does most of the work, represented by the &lt;span style="font-weight: bold;"&gt;ConcreteComponent &lt;/span&gt;class above, and one or more &lt;span style="font-weight: bold;"&gt;Decorator &lt;/span&gt;classes that inherits from the same base class as ConcreteComponent (the abstract &lt;span style="font-weight: bold;"&gt;Component &lt;/span&gt;class in the diagram above), and also holds onto a reference to a Component class.&lt;br /&gt;&lt;br /&gt;The Decorator classes delegate most of the real work to their Component class instance, but "decorate" its functionality by tacking on their own behavior.&lt;br /&gt;&lt;br /&gt;Note that in the diagram above the abstract DecoratorComponent doesn't add a lot of value - it defines a way to pass the reference to the Component class to the decorators, and nothing else. When there's only a single Decorator you can simplify the diagram like so:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/Sf_IiTWuINI/AAAAAAAAAKI/WOsUgPZh2Rc/s1600-h/decorator-simple.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 144px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/Sf_IiTWuINI/AAAAAAAAAKI/WOsUgPZh2Rc/s400/decorator-simple.jpg" alt="" id="BLOGGER_PHOTO_ID_5332200975466635474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Simplified Decorator Pattern&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;In fact even when there are multiple Decorator classes the base Decorator class is often omitted, as is the case in the CryptoStream example from the .NET Framework, which is shown below.&lt;br /&gt;&lt;br /&gt;The GoF book says that another name for this pattern is the Wrapper Pattern, but in my opionion "wrapper" is a loose term that applies to a number of patterns in which one object delegates most of its behavior to another, "contained" object. In particular, I'd say "wrapper" applies to the Decorator, &lt;a href="http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-4-facade.html"&gt;Fascade &lt;/a&gt;and &lt;a href="http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-for-net-part.html"&gt;Adapter &lt;/a&gt;patterns, but not to the &lt;a href="http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-for-net-part.html"&gt;Proxy &lt;/a&gt;pattern because in that case the object you are delegating to is not conceived of as being "contained in" the proxy.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;It's not terribly easy to find real-life examples of the Decorator Pattern. One of the examples given by the GoF is also the example given in &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc188707.aspx#S3"&gt;this MSDN article&lt;/a&gt; that describes the Decorator Pattern, which is the Stream family of classes:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sf_Pl2ACukI/AAAAAAAAAKY/fZx76GTvn6Y/s1600-h/decorator-example.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 130px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/Sf_Pl2ACukI/AAAAAAAAAKY/fZx76GTvn6Y/s400/decorator-example.jpg" alt="" id="BLOGGER_PHOTO_ID_5332208732887759426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;Decorator Pattern Example: A CryptoStream&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this example the CryptoStream class inherits from the abstract Stream class and is also given a Stream object reference, overrides the Write method, encrypts the bytes and then calls the Write method on the contained stream to write the encrypted bytes. In fact, if you use Reflector on the .NET Framework CryptoStream class you can see that it has actually been implemented using this pattern. The CryptoStream constructor takes a Stream reference:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode)&lt;br /&gt;{&lt;br /&gt;  this._stream = stream;&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And the Write method encrypts the buffer before writing it to the stream:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public override void Write(byte[] buffer, int offset, int count)&lt;br /&gt;{&lt;br /&gt;  // Bunch of encryption goo...&lt;br /&gt;  this._stream.Write(this._OutputBuffer, 0, num3);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The Decorator Pattern can provide a very elegant means of composing the behaviors of objects at run time. In the example above, because CryptoStream is passed an abstract Stream object base class reference, it can operate on any type of stream: a FileStream, MemoryStream or any type of stream that you may create in the future. And because CryptoStream itself derives from Stream, it can be passed to other decorators. So if in the future a CompressionStream class were created, you could compose a FileStream that is encrypted and compressed, or a MemoryStream that is compressed by not encrypted. All this can be done dynamically, at runtime, rather than at compile time, as would be the case if you were to attempt this via inheritance.&lt;br /&gt;&lt;br /&gt;Pros and Cons of the Decorator Pattern, according to the GoF:&lt;br /&gt;&lt;br /&gt;Pros:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Allows for more flexible composition of behaviors than static inheritance.&lt;/li&gt;&lt;li&gt;Allows you to break object behaviors into small components (as opposed, for example, to creating a CryptoCompressionStream class that inherits from CryptoStream)&lt;/li&gt;&lt;/ul&gt;Cons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Can lead to an explosion of small component classes are are difficult to understand.&lt;/li&gt;&lt;li&gt;Can't rely on object identity remaining unchanged because a client's initial Concrete object may be wrapped in a Decorator at any time.&lt;/li&gt;&lt;/ul&gt;And I think I should add that creating a Component base class definition that is amenable to this kind of infinitely forward-compatible extensibility is more difficult than it looks, because the Decorator classes have no ability to change the internal behavior of the Component, as they would with inheritance. This is probably why the Decorator Pattern isn't used more often in practice.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-2928754825036574264?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/2928754825036574264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/04/toms-patterns-cheat-sheet-decorator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/2928754825036574264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/2928754825036574264'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/04/toms-patterns-cheat-sheet-decorator.html' title='Tom&apos;s Patterns Cheat Sheet , Part 6 - The Decorator Pattern'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_-6lCnWdTHH4/Sf_FfRY8-4I/AAAAAAAAAKA/e-Mon8MTgUU/s72-c/decorator-basic.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-4895994406388049964</id><published>2009-03-17T23:21:00.001-07:00</published><updated>2009-03-18T23:32:59.410-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View ViewModel'/><category scheme='http://www.blogger.com/atom/ns#' term='Presentation Model'/><category scheme='http://www.blogger.com/atom/ns#' term='architectural patterns'/><title type='text'>A First Look at Model-View-ViewModel</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Model-View-ViewModel (MVVM) is a pattern used extensively by WPF developers. It was first introduced in October 2005 on WPF-and-Silverlight architect John Grossman's &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://blogs.msdn.com/johngossman/archive/2005/10/08/478683.aspx"&gt;blog&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, where it was billed as a variation of MVC. According to Grossman, Expression Blend was written entirely using the MVVM pattern, and it is now, as far as I can tell, far and away the most common pattern used by WPF programmers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I'm new to WPF and to MVVM, so I'm not going to claim to be able to make any definitive pronouncements about it. Most of what I've learned about it has come from reading &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx"&gt;this MSDN article&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, which was written by Infragistics engineer &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://joshsmithonwpf.wordpress.com/"&gt;Josh Smith&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, and which &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://blogs.msdn.com/johngossman/archive/2009/01/28/excellent-introduction-to-model-view-viewmodel.aspx"&gt;Grossman himself recommends&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, as well as from reading various blog posts and newsgroup threads. But I will attempt to give some initial impressions, which I will hopefully refine and correct over time.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; text-decoration: underline;font-family:verdana;" &gt;What is MVVM?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;First of all, even though Grossman and others refer to it as a variant of MVC, it appears to me that MVVM is &lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;exactly &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://martinfowler.com/eaaDev/PresentationModel.html"&gt;Presentation Model&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, which is why my &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://computing-tombarreras.blogspot.com/2009/03/toms-patterns-cheat-sheet-part-5.html"&gt;last post was a recap of Presentation Model&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;. So far as I can tell, there is no structural or conceptual difference between MVVM and Presentation Model that could be used to classify it as a separate pattern. It is simply the application of the simpler form of Presentation Model to WPF applications. Smith agrees with this, saying "I consider MVVM to be a specialization of the more general PM pattern, tailor-made for the WPF and Silverlight platforms."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; text-decoration: underline;font-family:verdana;" &gt;MVVM as an Adaptation of Presentation Model&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You may recall that the simpler form of Presentation Model that I discussed in my last post was this one:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div  style="text-align: center;font-family:verdana;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHLqhVTjoI/AAAAAAAAAJI/Q2ADIDPOfH4/s1600-h/PresentationModel1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 201px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHLqhVTjoI/AAAAAAAAAJI/Q2ADIDPOfH4/s400/PresentationModel1.jpg" alt="" id="BLOGGER_PHOTO_ID_5314752966636572290" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div  style="text-align: center;font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;Presentation Model pattern in which the View references the Presentation Model&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This is the simpler form because the view references the presentation model, and not vice versa, so the presentation model can be written without any entanglement with the view whatsoever. Also I mentioned in my last post that where data binding is present this pattern is especially simple, which is the case in MVVM. So here is the pattern as applied to WPF applications (from here on out I'll switch to the MVVM terminology and call the presentation model a "view model"):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div face="verdana" style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHPDoyTIeI/AAAAAAAAAJQ/DW0EHq_S-y8/s1600-h/MVVM1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 199px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHPDoyTIeI/AAAAAAAAAJQ/DW0EHq_S-y8/s400/MVVM1.jpg" alt="" id="BLOGGER_PHOTO_ID_5314756696668840418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div face="verdana" style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;MVVM Pattern&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold; text-decoration: underline;font-family:verdana;" &gt;WPF Elements in MVVM&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The diagram above is clear, but not very interesting. Here is a diagram that shows where the WPF pieces fall into the MVVM pattern (click on the image to see a larger version):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center; font-family: verdana;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHax0E66_I/AAAAAAAAAJg/J8g-NeBaQSQ/s1600-h/MVVM2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 148px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHax0E66_I/AAAAAAAAAJg/J8g-NeBaQSQ/s400/MVVM2.jpg" alt="" id="BLOGGER_PHOTO_ID_5314769584601623538" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center; font-family: verdana;"&gt;&lt;span style="font-style: italic;"&gt;WPF Elements in the MVVM Pattern&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I'll be the first to admit that I may be focusing myopically on the sample program that Smith provides with his article. I'll update this as I learn more, but meanwhile, based on that example and on a smattering of reading, this is what I see:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;View&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;: Consists of all of the XAML in the application, including the XAML for the main Application, for the Windows and for any UserControls, plus any Styles and DataTemplates. WPF data binding is used to bind controls to view model classes, and DataTemplates map view models to WPF controls for presentation.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Once the developer puts the basic view in place, they would ship it off to a UI designer in accordance with Microsoft's strategy of separating those two roles, so the view model needs to be well separated from the view.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;View Model:&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; Application, Window and UserControl XAML code-behind falls into the View Model layer, but it is strongly recommended that code-behind code be minimized, and that View Model code be placed in separate classes to the extent possible. Those classes are the view model classes shown above. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;View model classes are data-bound to the view, so they need to implement INotifyPropertyChanged in order to notify the view when it needs to be updated. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;They may optionally expose Command properties, which are classes that implement the ICommand interface. WPF provides built-in support for a command pattern that allows you to easily associate a single handler with a menu item, toolbar button, context menu, short cut key, etc. E.g. you can associate a single "Copy" command handler with the "Copy" menu item, toolbar button, context menu and "Ctrl-C" shortcut key. Commands therefore provide a way to encapsulate some of the behavior of the WPF application in the view model classes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Granularity of view models appears to be roughly one per Application, Window and UserControl, but that isn't set in stone.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Domain Model:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Happily, our domain model never changes as we move from pattern to pattern. That's one of the best things about these patterns. Our efforts to create controllers that can be reused from one UI technology to another only rarely prove fruitful (what are we supposed to do with all those Windows Forms MVP presenters now that we're told we should use data binding in WPF applications?) But the domain models just keep chugging right along, oblivious to the world's UI churn. They are the only (mostly) completely reusable parts of the system we have.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Anyway that's it for my first look at MVVM. I will (hopefully) try to update this as I continue to learn about WPF.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-4895994406388049964?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/4895994406388049964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/03/first-look-at-model-view-viewmodel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4895994406388049964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/4895994406388049964'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/03/first-look-at-model-view-viewmodel.html' title='A First Look at Model-View-ViewModel'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_-6lCnWdTHH4/ScHLqhVTjoI/AAAAAAAAAJI/Q2ADIDPOfH4/s72-c/PresentationModel1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-1717662775906521143</id><published>2009-03-16T23:21:00.000-07:00</published><updated>2009-03-17T23:22:13.660-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVVM'/><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='MVP'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View Presenter'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View ViewModel'/><category scheme='http://www.blogger.com/atom/ns#' term='Presentation Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View Controller'/><title type='text'>Tom’s Patterns Cheat Sheet, Part 5 – Presentation Model</title><content type='html'>&lt;span style="font-weight: bold; text-decoration: underline;font-family:verdana;" &gt;Overview&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Presentation Model (also called Application Model) is a pattern that is similar to the MVC family of patterns in that it consists of a domain model, a view and a "something else" that acts as a mediator between the model and the view.&lt;br /&gt;&lt;br /&gt;That "something else" is the &lt;/span&gt;&lt;span style="font-style: italic;font-family:verdana;" &gt;presentation model&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;. &lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;A presentation model differs from the controller in MVC and the presenter in MVP primarily in the way it is conceived. A presentation model is conceptually an object model that represents the view. E.g. if your view contains two textboxes and a checkbox, you would expect to see two string properties and a boolean property in the presentation model:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;  &lt;div  style="text-align: center;font-family:verdana;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ScBr0FFf5aI/AAAAAAAAAIo/cewHoFKuzx8/s1600-h/SamplePresentationModel.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 287px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ScBr0FFf5aI/AAAAAAAAAIo/cewHoFKuzx8/s400/SamplePresentationModel.jpg" alt="" id="BLOGGER_PHOTO_ID_5314366102759794082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt; &lt;div  style="text-align: center;font-family:verdana;"&gt;&lt;span style="font-style: italic;"&gt;Simple Presentation Model Example&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt; &lt;span style="font-family:verdana;"&gt;In this example, the logic associated with enabling or disabling the "Offline enabled" checkbox is handled by the presentation model, as is the code that interacts with the domain model, which is in this case the authentication service.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Controllers and presenters, in contrast, are conceptually handler classes that act as conduits between the domain model and the view. &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;A presentation model is stateful, because it is considered the "system of record" for view state, while presenters and controllers are likely to be stateless. In fact Fowler &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;comments&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; that "the basic MVC notion assumes that all the state of the view can be derived from the state of the model," so in classic MVC there is no view state.&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Controllers, using Martin Fowler's &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;description of MVC&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, tends to be very granular - one ore more controllers for every widget. Presenters tend to be more large-grained - typically one per form. Presentation models tend to be larger-grained as well, similar to presenters, although composition of presentation models is also common, particularly in the Model-View-ViewModel (MVVM) variant used by WPF developers.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="text-decoration: underline;font-family:verdana;" &gt;&lt;span style="font-weight: bold;"&gt;Components of Presentation Model&lt;/span&gt;&lt;/span&gt;   &lt;span style="font-weight: bold;font-family:verdana;" &gt;&lt;br /&gt;&lt;br /&gt;The presentation model&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;: &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;An abstraction for a view's state and behaviors. Like the presenter in MVP, the presentation model is intended to be free of UI dependencies, and for the same reason: One of the primary motivations for Presentation Model is to improve the testability of the system by moving as much logic as possible out of the view, where it is difficult to test.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:verdana;" &gt;The view: &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;As in &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;MVP, the view in the Presentation Model pattern is intended to be as free of logic as possible, again to improve testability.&lt;/span&gt;   &lt;span style="font-weight: bold;font-family:verdana;" &gt;&lt;br /&gt;&lt;br /&gt;The domain model: &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;The domain model is conceptually the same in Presentation Model as in MVP.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;font-family:verdana;" &gt;&lt;span style="font-weight: bold;"&gt;Variations of Presentation Model&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Fowler identifies two variations of Presentation Model, one in which the view references the presentation model, and one in which the presentation model references the view:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;  &lt;div face="verdana" style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/ScB_VQdepcI/AAAAAAAAAIw/wEoETOQKc-4/s1600-h/PresentationModel1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 201px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/ScB_VQdepcI/AAAAAAAAAIw/wEoETOQKc-4/s400/PresentationModel1.jpg" alt="" id="BLOGGER_PHOTO_ID_5314387563469776322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt; &lt;div face="verdana" style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;Presentation Model pattern in which the View references the Presentation Model&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="text-align: center; font-family: verdana;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/ScCBagNaV4I/AAAAAAAAAJA/oxN-JFwWny0/s1600-h/PresentationModel2.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 210px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/ScCBagNaV4I/AAAAAAAAAJA/oxN-JFwWny0/s400/PresentationModel2.jpg" alt="" id="BLOGGER_PHOTO_ID_5314389852619954050" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center; font-family: verdana;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;Presentation Model pattern in which the Presentation Model references the View&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt; &lt;span style="font-family:verdana;"&gt;Fowler provides a code sample of the first variant &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://martinfowler.com/eaaDev/PresentationModel.html"&gt;here&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;. This variant is simpler than the second one, especially in cases where data binding can be used or where the Presentation Model-&gt;View observer can be dispensed with, because the presentation model has no dependencies on the view at all, or even on a view interface. &lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;But if data binding is not available and if you want to test the code that synchronizes the presentation model's state with the view, then the presentation model will need a reference to the view, so the second option is required.&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;Another important variation is MVVM, which is used extensively by the WPF community. I will attempt to comment on that pattern in the next post.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;font-family:verdana;" &gt;&lt;span style="font-weight: bold;"&gt;Pros and Cons of Presentation Model&lt;/span&gt;&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;As with MVP, one of the main motivations for using Presentation Model is to improve the testability of the system.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;As with any &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://martinfowler.com/eaaDev/SeparatedPresentation.html"&gt;Separated Presentation&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; pattern, following the pattern may make it easier to support multiple views or to change UI technologies, although in practice this benefit is often overstated.&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;As with MVC and MVP, Presenter Model allows you to separate the UI technology from the UI logic, which makes the code easier to understand and to maintain. Compared to MVP, Presentation Model can lead to a cleaner, simpler presenter / presentation model object model, because by encapsulating view state as well as behavior the presentation model disentangles itself entirely from the view.&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Presentation Model may lend itself better than MVP to situations in which you want to create an automation object model for your user interface that would be usable by SDK programmers, because the presentation model object model is closer to what a programmer would expect to see in an automation object model. Although some developers have exposed the MVP presenter for use in this way, they generally are not as user-friendly as presentation models.&lt;/span&gt;  &lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;On the downside, because it maintains its own view state, Presentation Model introduces the need to synchronize the view and the presentation model, although this can be mitigated by data binding. It makes use of the Observer pattern, which decreases readability and maintainability of the system. And it increases the number of moving parts in the system, which can decrease maintainability in small applications.&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/5119957131131393001-1717662775906521143?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/1717662775906521143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/03/toms-patterns-cheat-sheet-part-5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/1717662775906521143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/1717662775906521143'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/03/toms-patterns-cheat-sheet-part-5.html' title='Tom’s Patterns Cheat Sheet, Part 5 – Presentation Model'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_-6lCnWdTHH4/ScBr0FFf5aI/AAAAAAAAAIo/cewHoFKuzx8/s72-c/SamplePresentationModel.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-7462573942045153731</id><published>2009-02-25T00:26:00.001-08:00</published><updated>2009-02-25T00:34:01.621-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Bridge Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='Facade Pattern'/><title type='text'>Tom’s Patterns Cheat Sheet, Part 4 – Façade and Bridge Patterns</title><content type='html'>&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;For this post I'm reverting to the original patterns Bible as my primary source, the GoF &lt;a href="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1235535249&amp;amp;sr=8-1"&gt;Design Patterns&lt;/a&gt; tome.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Façade&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div face="verdana" style="text-align: center; font-family: trebuchet ms;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SaUA8JA939I/AAAAAAAAAIQ/2e-6GyQ_rHs/s1600-h/facade.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 150px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SaUA8JA939I/AAAAAAAAAIQ/2e-6GyQ_rHs/s400/facade.jpg" alt="" id="BLOGGER_PHOTO_ID_5306648769138122706" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;   &lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;em&gt;The Façade Pattern&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Provides a simple interface to a complex subsystem. Helps decouple clients from the individual elements of a subsystem. Useful for enforcing layering of subsystems. Web service interfaces to legacy systems are good examples of the façade pattern:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div face="verdana" style="text-align: center; font-family: trebuchet ms;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8KuDHYI/AAAAAAAAAII/OXk4kSnBJ4I/s1600-h/facade+ws.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 281px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8KuDHYI/AAAAAAAAAII/OXk4kSnBJ4I/s400/facade+ws.jpg" alt="" id="BLOGGER_PHOTO_ID_5306648769595645314" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;   &lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center; font-family: trebuchet ms;"&gt;&lt;span xmlns=""&gt;&lt;p&gt;&lt;span xmlns=""&gt;&lt;em&gt;Web Services Example of The Façade Pattern&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Bridge Pattern&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center; font-family: trebuchet ms;"&gt;&lt;span xmlns=""&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8LyXT6I/AAAAAAAAAIA/6ntrLQngy_k/s1600-h/bridge.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 184px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8LyXT6I/AAAAAAAAAIA/6ntrLQngy_k/s400/bridge.jpg" alt="" id="BLOGGER_PHOTO_ID_5306648769882181538" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p style="text-align: center;"&gt;&lt;em&gt;The Bridge Pattern&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;"Decouples an abstraction from an implementation." In other words, allows you to create a separate class hierarchy for the object model that the client cares about (the "abstraction") and for the object model that internally implements its functionality.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A trivial example might be a Customers class that internally uses an ADO recordset for data access:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center; font-family: trebuchet ms;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8LbL1wI/AAAAAAAAAH4/fPilf1vmJZs/s1600-h/bridge+trivial.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 180px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaUA8LbL1wI/AAAAAAAAAH4/fPilf1vmJZs/s400/bridge+trivial.jpg" alt="" id="BLOGGER_PHOTO_ID_5306648769784960770" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;   &lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;em&gt;Trivial application of the Bridge Pattern&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;This is a trivial case because the implementer can't be subclassed, but it could still be useful for cases where you want to be able to inject ADO recordsets with different data sources into your Customers object, without having to change the Customers class itself.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;We can make this example slightly more sophisticated by replacing the recordset with a generic data access class that could be specialized to use ADO, XML, flat files or whatever:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center; font-family: trebuchet ms;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SaUA7-GZv8I/AAAAAAAAAHw/r2Fl_k5pCTw/s1600-h/bridge+less+trivial.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 169px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SaUA7-GZv8I/AAAAAAAAAHw/r2Fl_k5pCTw/s400/bridge+less+trivial.jpg" alt="" id="BLOGGER_PHOTO_ID_5306648766208131010" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-family: trebuchet ms;font-family:verdana;" xmlns="" &gt;&lt;p&gt;   &lt;/p&gt;&lt;p style="text-align: center;"&gt;&lt;em&gt;Application of the Bridge Pattern&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;A good code sample of this type of application of the bridge pattern can be found &lt;a href="http://www.dofactory.com/Patterns/PatternBridge.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This is useful when&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You would like to reuse the implementer outside the context of the abstraction. A recordset implementer is a good example of this.&lt;/li&gt;&lt;li&gt;You need the ability to swap out implementations at runtime. A recordset that can be configured to use multiple data sources is an example. Machine- or OS-specific implementations are another example, e.g. an XP v. Vista implementations.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;You want to simplify the class hierarchies and/or provide greater extensibility flexibility by splitting up the system into separate class hierarchies for the abstraction and its implementation.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-7462573942045153731?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/7462573942045153731/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-4-facade.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/7462573942045153731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/7462573942045153731'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-4-facade.html' title='Tom’s Patterns Cheat Sheet, Part 4 – Façade and Bridge Patterns'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_-6lCnWdTHH4/SaUA8JA939I/AAAAAAAAAIQ/2e-6GyQ_rHs/s72-c/facade.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-6604809568473186638</id><published>2009-02-18T22:09:00.001-08:00</published><updated>2009-02-21T13:40:31.729-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVP'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View Presenter'/><category scheme='http://www.blogger.com/atom/ns#' term='architectural patterns'/><title type='text'>Tom’s Patterns Cheat Sheet, Part 3 – Model View Presenter</title><content type='html'>&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;Considered a descendant of Model View Controller, MVP comes in two main forms, which patterns god Martin Fowler calls &lt;a href="http://martinfowler.com/eaaDev/SupervisingPresenter.html"&gt;Supervising Controller&lt;/a&gt; and &lt;a href="http://martinfowler.com/eaaDev/PassiveScreen.html"&gt;Passive View&lt;/a&gt;. A significant variant of Passive View is the Humble View, which is epitomized by Michael Feathers' classic article &lt;a href="http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf"&gt;The Humble Dialog Box&lt;/a&gt;, and a very significant variation of that is &lt;a href="http://www.atomicobject.com/files/PresenterFirstAgile2006.pdf"&gt;Presenter First&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Most discussions of MVP begin with MVC and proceed in chronological order, but I find this ordering illogical. From a practical standpoint, the primary reason to choose MVP is to increase testability of your UIs, so the logical starting point is the Humble View form of Passive View.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Passive View MVP&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZz4I6OE9OI/AAAAAAAAAGY/mt-8GVZCZck/s1600-h/mvp+passive.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 166px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZz4I6OE9OI/AAAAAAAAAGY/mt-8GVZCZck/s400/mvp+passive.jpg" alt="" id="BLOGGER_PHOTO_ID_5304387293086545122" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;   &lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;&lt;em&gt;Passive View MVP&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;Dotted lines represent communication by events while solid lines are direct object messages. The roles of the components are as follows.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt; In this architecture the view is kept as "humble" (that is, as free of code and logic) as possible. UI technology is often difficult to unit test (though as Fowler &lt;a href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;says&lt;/a&gt;, this point is often over-stated) so the goal of Humble View is to remove anything from the view that might be worth testing. The view will generally not be covered by unit tests at all in this architecture.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Presenter:&lt;/strong&gt; The view simply passes notification of user stimulus to the presenter, whose role is similar to a controller in MVC. The presenter accesses the view only through a UI-agnostic interface so that it can be easily mocked in unit tests. The presenter updates the model appropriately and can receive events from the model when its state changes. The presenter is entirely responsible for updating the view; the view has no direct knowledge of or interaction with the model. The reason for this is to simplify the logic and make the code more readable and maintainable by putting all UI manipulation code in a single place.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A presenter differs from a controller primarily in its granularity: presenters are created at the form/page/complex widget level, and not at the widget/window level as are controllers. Also in Passive View MVP presenters are responsible for updating the view as well as for responding to user interaction, while controllers are only responsible for the latter.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt; As with MVC, the model has no knowledge of the presenter or the view.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Some other variations on Passive View:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZz4I5OUjZI/AAAAAAAAAGQ/jA8qq83YZ84/s1600-h/mvp+passive+observer+of+view.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 166px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZz4I5OUjZI/AAAAAAAAAGQ/jA8qq83YZ84/s400/mvp+passive+observer+of+view.jpg" alt="" id="BLOGGER_PHOTO_ID_5304387292819131794" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;   &lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;&lt;em&gt;Passive View MVP with a Presenter-Model Observer&lt;/em&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;By removing the View's direct knowledge of the presenter you can decouple the view from the presenter and allow the same view to be used with different presenters. There is however a penalty to be paid in loss of readability whenever the Observer pattern is used, and this can sometimes be significant.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZz4I77qHII/AAAAAAAAAGI/u432Dt7AnM4/s1600-h/mvp+passive+observer+of+view+with+imodel.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 166px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZz4I77qHII/AAAAAAAAAGI/u432Dt7AnM4/s400/mvp+passive+observer+of+view+with+imodel.jpg" alt="" id="BLOGGER_PHOTO_ID_5304387293546159234" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;   &lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;&lt;em&gt;Passive View MVP with a Model Interface&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;By adding an interface for the model you can improve testability of the presenter yet again. This can be used with or without the Presenter-View Observer. In fact I would encourage use of a model interface for all but the most trivial of models. At this point we've arrived at the MVP variant used by Presenter First, though Presenter First is really a variation of TDD, and so is as much a design/development process as an architecture.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It should be noted that Fowler considers the View interface optional, but from a practical standpoint we can assume its existence.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Supervising Controller&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Historically, Supervising Controller was developed before Passive View, but logically it's the pattern you revert to in order to take advantage of data binding:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZz4I0zOElI/AAAAAAAAAGA/IBwvcPN-TwE/s1600-h/mvp+supervising+controller.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 166px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZz4I0zOElI/AAAAAAAAAGA/IBwvcPN-TwE/s400/mvp+supervising+controller.jpg" alt="" id="BLOGGER_PHOTO_ID_5304387291631718994" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;   &lt;/p&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;&lt;em&gt;Supervising Controller MVP&lt;/em&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span xmlns=""  style="font-family:trebuchet ms;"&gt;&lt;p&gt;With this pattern you would allow data binding of the model to the view to handle the "easy" synchronization work, and would reserve the presenter for handling any complex logic. Although this is structurally more complex than Passive View, in practice where data binding is strong it can result in far simpler code. The Presenter-Model Observer has been removed from the diagram above, but there's no reason it couldn't be added back if that were appropriate for the situation.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For additional variations on MVP, I found &lt;a href="http://ctrl-shift-b.com/2008/11/model-view-presenter-styles.html"&gt;this&lt;/a&gt; to be an interesting post. I will reserve creation of MVP code samples for a future post.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&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/5119957131131393001-6604809568473186638?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/6604809568473186638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-3-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/6604809568473186638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/6604809568473186638'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-3-model.html' title='Tom’s Patterns Cheat Sheet, Part 3 – Model View Presenter'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_-6lCnWdTHH4/SZz4I6OE9OI/AAAAAAAAAGY/mt-8GVZCZck/s72-c/mvp+passive.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-401189903310948829</id><published>2009-02-18T00:16:00.001-08:00</published><updated>2009-02-18T00:20:57.382-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='Model View Controller'/><title type='text'>Tom’s Patterns Cheat Sheet, Part 2 – Model View Controller</title><content type='html'>&lt;span style="font-family: verdana;" xmlns=""&gt;&lt;p&gt;MVC is one of the oldest, most widely known architectural patterns. It involves decomposition of the system into three parts, using terminology from patterns god Martin Fowler's  &lt;a href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;GUI Architectures&lt;/a&gt; paper:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Model:  domain object model.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;View: user interface that displays the state of the model.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Controller: an object that receives user input and updates the model, and possibly the view.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here's the usual MVC dependency diagram:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZvEihpiDzI/AAAAAAAAAF4/BdbjrhPyMPE/s1600-h/mvc.jpg"&gt;&lt;img style="cursor: pointer; width: 296px; height: 140px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZvEihpiDzI/AAAAAAAAAF4/BdbjrhPyMPE/s400/mvc.jpg" alt="" id="BLOGGER_PHOTO_ID_5304049083586055986" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;This means the model is independent of (has no knowledge of) the views and the controllers, the view and the controller have strong knowledge of the model, and the controller has knowledge of the view. So we would expect, for example, to be able to make drastic changes in the view without affecting the model at all, but changes in the model will probably mandate changes in the view.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;MVC has two primary uses: rich client GUIs and thin client Web applications. It was originally developed for rich client UIs, but in that space it has mostly been superseded by other patterns. But it's alive and well in the web space, and is the basis of both &lt;a href="http://wiki.rubyonrails.org/rails/pages/UnderstandingRailsMVC"&gt;Ruby on Rails&lt;/a&gt; and &lt;a href="http://www.asp.net/learn/mvc/tutorial-01-cs.aspx"&gt;ASP.NET MVC&lt;/a&gt;. See &lt;a href="http://msdn.microsoft.com/en-us/library/ms978748.aspx"&gt;this MSDN article&lt;/a&gt; for a good overview.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;MVC in Rich client GUIs&lt;/span&gt;: mainly uses a variant called &lt;em&gt;active model&lt;/em&gt;. "Active" because the model takes action (notifies an observer, raises an event) that lets views and controllers know when its state has changed. The general data flow goes like this:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;User stimulus happens, controller receives the event (often without the view's involvement at all)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Controller updates the model&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Model raises a data changed event&lt;br /&gt;&lt;/li&gt;&lt;li&gt;View traps the event and updates itself&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Graphically this looks as follows. A good example of this can be found &lt;a href="http://www.enode.com/x/markup/tutorial/mvc.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SZvEikPvoFI/AAAAAAAAAFw/nKfRa8NSbiE/s1600-h/mvc+flow.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 123px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SZvEikPvoFI/AAAAAAAAAFw/nKfRa8NSbiE/s400/mvc+flow.jpg" alt="" id="BLOGGER_PHOTO_ID_5304049084283199570" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;Dotted lines are used to indicate communication via events, solid lines to indicate direct manipulation. Some notes:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;There may be multiple views and multiple controllers working off a single model.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The controller and the view don't depend on one another in this picture. Martin Fowler actually leaves the controller -&amp;gt; view dependency off his dependency chart because, he says, it's not often used in the rich client GUI case. It is used commonly in the web case however.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;This is often implemented at a very low level of granularity – one MV pair for each widget, or even for each window in each widget.&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In that case the "model" may represent a value stored in a widget, and not in a database.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Pros:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Separation of model from view. Allows changes in the view without affecting the model. Good for cases where the views change more frequently than the model, as is usually the case.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Cons:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use of observers/events increases complexity.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Frequent updates to the model could result in many data changed events and suboptimal performance.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Separates view from model &lt;em&gt;writes&lt;/em&gt;, but not from model reads. Since views are difficult to unit test, this means logic involved in transforming model data for presentation is not covered.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;MVC in Web applications&lt;/strong&gt;&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Uses a variant called &lt;em&gt;passive model&lt;/em&gt;. "Passive" because the model makes no effort to inform anyone that its state has changed. Flow is as follows:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;HTTP request happens, controller on the server receives the request.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Controller updates the model, usually resulting in a database update.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Controller selects the view appropriate for the request, provides it with any model data it needs, and returns it, typically in the form of HTML, XML or JavaScript.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The browser renders the view.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZvEiQQFBsI/AAAAAAAAAFo/ShAXu5YdBU8/s1600-h/mvc+web+flow.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 82px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SZvEiQQFBsI/AAAAAAAAAFo/ShAXu5YdBU8/s400/mvc+web+flow.jpg" alt="" id="BLOGGER_PHOTO_ID_5304049078915892930" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;This looks like any well factored web application that you've ever seen, in which the domain model is carefully separated from the web UI code, but there is an important difference. In MVC web applications the web UI code is separated logically and physically into separate view and controller elements. Some notes:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The view is as simple as possible, usually just an HTML template containing some simple server-side code snippets.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The controller is designed for maximum testability. In the case of ASP.NET MVC, it is free of UI and web server dependencies, which the ASP.NET MVC framework provides to the controller via easily mocked interfaces. In the case of Rails, controllers are &lt;a href="http://guides.rubyonrails.org/testing_rails_applications.html"&gt;designed to be easily testable using functional tests&lt;/a&gt;.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The view and controller are larger grained than in the rich-client case, generally at the level of one controller/view per page.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Pros:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Separation of controller from model helps manage complexity of large web applications.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Designed to support Test Driven Development (TDD).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Cons:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;For small to medium sized web applications, increases complexity.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&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/5119957131131393001-401189903310948829?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/401189903310948829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-2-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/401189903310948829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/401189903310948829'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-part-2-model.html' title='Tom’s Patterns Cheat Sheet, Part 2 – Model View Controller'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_-6lCnWdTHH4/SZvEihpiDzI/AAAAAAAAAF4/BdbjrhPyMPE/s72-c/mvc.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-8044135123775114903</id><published>2009-02-16T14:15:00.001-08:00</published><updated>2009-02-24T23:05:26.503-08:00</updated><title type='text'>Tom’s Patterns Cheat Sheet for .NET – Part 1: Template Method, Strategy, Observer, Adapter, Proxy Patterns</title><content type='html'>&lt;span xmlns=""&gt;&lt;p&gt;This post started as a brownbag presentation I put together last year on Russ Olsen's &lt;a href="http://www.amazon.com/Design-Patterns-Ruby-Addison-Wesley-Professional/dp/0321490452/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1234235575&amp;amp;sr=8-1"&gt;Design Patterns in Ruby&lt;/a&gt;, so he deserves attribution. Parts also are based on Jeffrey Richter's classic &lt;a href="http://www.amazon.com/Applied-Microsoft%C2%AE-Framework-Programming-Pro-Developer/dp/0735614229"&gt;Applied Microsoft® .NET Framework Programming&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Template method&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SZnnkyMakdI/AAAAAAAAAFg/U82iQdY9fVQ/s1600-h/templatemethod.jpg"&gt;&lt;img style="cursor: pointer; width: 321px; height: 328px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SZnnkyMakdI/AAAAAAAAAFg/U82iQdY9fVQ/s400/templatemethod.jpg" alt="" id="BLOGGER_PHOTO_ID_5303524655340622290" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;The template method implements an algorithm that makes use of the virtual or abstract methods, which subclasses can specialize.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;pre&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;    &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;AbstractClass&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; TemplateMethod()&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;br /&gt;            &lt;span style="color:green;"&gt;// A real template method example would implement a more complex algorithm&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            Operation1();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            Operation2();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            Operation3();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            Operation4();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;br /&gt;        &lt;span style="color:green;"&gt;// These operations may be abstract or virtual&lt;br /&gt;        &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color:black;"&gt;Operation1();&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color:black;"&gt;Operation2();&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color:black;"&gt;Operation3();&lt;/span&gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; &lt;span style="color:black;"&gt;Operation4();&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;This is useful when the outline of an algorithm is fixed but the specific implementations of pieces of the algorithm may change. E.g. a class that encrypts and compresses data might delegate the specific encryption and compression algorithms to use to subclasses.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Strategy Pattern&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Traditional strategy pattern diagram:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_-6lCnWdTHH4/SaTsfG1pORI/AAAAAAAAAHo/Ff3OSLpmMLs/s1600-h/strategy4.jpg"&gt;&lt;img style="cursor: pointer; width: 256px; height: 196px;" src="http://4.bp.blogspot.com/_-6lCnWdTHH4/SaTsfG1pORI/AAAAAAAAAHo/Ff3OSLpmMLs/s400/strategy4.jpg" alt="" id="BLOGGER_PHOTO_ID_5306626280104999186" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;You might think of this as "algorithm injection." The "strategy" object is just a wrapper for a method. Clients "inject" the method they want to use by implementing their own strategy object and injecting it into the context. Similar to the template method pattern, but the client in this case doesn't have to subclass the class containing the template method.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In these days of anonymous methods, lambda methods, and code blocks the traditional strategy pattern diagram looks like a circumlocution. Nowadays we would rather visualize passing method contents around directly, without the need for an object wrapper, even if the compiler is really providing the object behind the scenes. I'm not really sure how to draw it in UML, but it would look something like this:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SZnnXVwS8qI/AAAAAAAAAFQ/k0niZdVDzPA/s1600-h/strategy2.jpg"&gt;&lt;img style="cursor: pointer; width: 206px; height: 123px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SZnnXVwS8qI/AAAAAAAAAFQ/k0niZdVDzPA/s400/strategy2.jpg" alt="" id="BLOGGER_PHOTO_ID_5303524424368190114" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;where the code blocks are the strategy operation method contents. A simple example of the strategy pattern:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;pre&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;       &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; animals = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt; { &lt;span style="color: rgb(163, 21, 21);"&gt;"lion"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"tiger"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"giraffe"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"elephant"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"fox"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"dog"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"bear"&lt;/span&gt; };&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;       animals.Sort(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Comparison&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;gt;((x, y) =&amp;gt; x.Length.CompareTo(y.Length)));&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="color:black;"&gt;&lt;br /&gt;List&amp;lt;string&amp;gt; is the context. Comparison&amp;lt;string&amp;gt; is just a delegate; that's the strategy. (x, y) =&amp;gt; x.Length.CompareTo(y.Length) is a lambda method; that's the strategy operation method contents.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Observer Pattern&lt;/strong&gt;&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_-6lCnWdTHH4/SaTsfLmaQdI/AAAAAAAAAHg/eI-utBMsvCA/s1600-h/observer1.jpg"&gt;&lt;img style="cursor: pointer; width: 376px; height: 196px;" src="http://1.bp.blogspot.com/_-6lCnWdTHH4/SaTsfLmaQdI/AAAAAAAAAHg/eI-utBMsvCA/s400/observer1.jpg" alt="" id="BLOGGER_PHOTO_ID_5306626281383281106" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;The object being observed keeps a list of objects that are observing it, and calls a notification method in each observer whenever its state changes. Objects register themselves to observe a subject by calling its AddObserver method, and unregister themselves by calling the RemoveObserver method. Simple implementation of the observer pattern:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;pre&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;    &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Observer&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;abstract&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; NotifyChanged(&lt;span style="color: rgb(43, 145, 175);"&gt;Subject&lt;/span&gt; subject);&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    }&lt;/span&gt;&lt;br /&gt; &lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;    &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Subject&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Observer&lt;/span&gt;&amp;gt; Observers = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Observer&lt;/span&gt;&amp;gt;();&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;bool&lt;/span&gt; _foo = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; NotifyObservers()&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;           &lt;span style="color:blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Observer&lt;/span&gt; observer &lt;span style="color:blue;"&gt;in&lt;/span&gt; Observers)&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                observer.NotifyChanged(&lt;span style="color:blue;"&gt;this&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; Foo&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;           &lt;span style="color:blue;"&gt;set&lt;/span&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _foo = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                NotifyObservers();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    }&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;&lt;/pre&gt;&lt;p&gt;For the sake of brevity I'm publicly exposing the List&amp;lt;Observer&amp;gt; observers field. Its Add and Remove methods will act as the AddObserver and RemoveObserver methods. When the state of the subject changes, it iterates the observer list, calling their NotifyChanged methods.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The above code isn't very practical in C# due to its lack of support for multiple inheritance. Any observer would burn its one and only base class just so it could listen to the subject's notifications. Instead, we would want to create a delegate for the NotifyChanged method, which the observers could use to have the subject call back to them when the subject changes.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I have a good friend whose favorite interview question for .NET engineers is, "How do you implement the observer pattern in .NET?" It stumps most candidates because .NET provides such deep native support for the pattern that we tend not to think about it:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;pre&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;    &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Subject&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;event&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EventHandler&lt;/span&gt; Changed;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;bool&lt;/span&gt; _foo = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OnChanged(&lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            Changed(&lt;span style="color:blue;"&gt;this&lt;/span&gt;, e);&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; Foo&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;           &lt;span style="color:blue;"&gt;set&lt;/span&gt; {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _foo = &lt;span style="color:blue;"&gt;value&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                OnChanged(&lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt;.Empty);&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    }&lt;/span&gt;&lt;br /&gt; &lt;/pre&gt;&lt;/p&gt;&lt;p&gt;The "event" keyword hydrates into a lot of observer goodness. First, it causes the compiler to auto-generate the delegate for the Changed method that I said we would want above. Remember that a delegate is just a class. This takes the place of the abstract Observer class in the first code listing. Second, it causes a delegate field to be added to the Subject class. This takes the place of the Observers field in the first code listing. And finally, it causes Add and Remove methods to be added to the Subject class.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;.NET delegates come with built-in support for "delegate chaining," or managing lists of delegates. So the auto-generated delegate field can already handle lists observers, and the Changed(this, e) call automatically iterates the list.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Adapter Pattern&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaTsewKF6TI/AAAAAAAAAHY/MNzjBVDN0nw/s1600-h/adapter1.jpg"&gt;&lt;img style="cursor: pointer; width: 366px; height: 167px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaTsewKF6TI/AAAAAAAAAHY/MNzjBVDN0nw/s400/adapter1.jpg" alt="" id="BLOGGER_PHOTO_ID_5306626274016749874" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;The goal of the pattern is to wrap the "adaptee" in a class that matches the interface expected by the client. It's useful when you have an existing class that provides the functionality needed by the client, but using a different interface than the one it expects. Here's a simple code sample of the adapter pattern:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;span style="color:blue;"&gt;    using&lt;/span&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;span style="color:blue;"&gt;    using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;span style="color:blue;"&gt;    using&lt;/span&gt; System.Linq;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;span style="color:blue;"&gt;    using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;span style="color:blue;"&gt;    namespace&lt;/span&gt; Adapter&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Client&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Target&lt;/span&gt; _target;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; Client(&lt;span style="color: rgb(43, 145, 175);"&gt;Target&lt;/span&gt; target) {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _target = target;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Foo() {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _target.OperationA();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Target&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;           &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;virtual&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OperationA() { }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Adaptee&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OperationB() {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;               &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;"Performed OperationB"&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Adapter&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;Target&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Adaptee&lt;/span&gt; _adaptee;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; Adapter(&lt;span style="color: rgb(43, 145, 175);"&gt;Adaptee&lt;/span&gt; adaptee) {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _adaptee = adaptee;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; OperationA() {&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                _adaptee.OperationB();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;        &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Program&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;            &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            {&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;Client&lt;/span&gt; client = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Client&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Adapter&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Adaptee&lt;/span&gt;()));&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;                client.Foo();&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;&lt;br /&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.ReadLine();&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;            }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;        }&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:10;"  &gt;    }&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Proxy Pattern&lt;/strong&gt;&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaTseosesrI/AAAAAAAAAHQ/VcCLW_BRBms/s1600-h/proxy1.jpg"&gt;&lt;img style="cursor: pointer; width: 267px; height: 176px;" src="http://3.bp.blogspot.com/_-6lCnWdTHH4/SaTseosesrI/AAAAAAAAAHQ/VcCLW_BRBms/s400/proxy1.jpg" alt="" id="BLOGGER_PHOTO_ID_5306626272013497010" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;The proxy pattern is used for inserting a class between clients and the real service that they are connecting to. Common types of proxies include &lt;strong&gt;protection proxies&lt;/strong&gt;, which perform an access check before allowing the client to call the service, and &lt;strong&gt;remote proxies&lt;/strong&gt;, which encapsulate the complexities of making method calls on a service in another process or on another machine.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Proxies are everywhere. If we create a console application in Visual Studio, and add a service reference to a default WCF service, Visual Studio auto-generates one for us:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZnnWwBvLAI/AAAAAAAAAEw/zPJsjnan32k/s1600-h/ide.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 215px;" src="http://2.bp.blogspot.com/_-6lCnWdTHH4/SZnnWwBvLAI/AAAAAAAAAEw/zPJsjnan32k/s400/ide.jpg" alt="" id="BLOGGER_PHOTO_ID_5303524414240795650" border="0" /&gt;&lt;/a&gt;   &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Service1Client is a client proxy that implements the IService1 interface. "GetData" is the operation implemented by the service. In this case the proxy doesn't match the traditional diagram exactly, because the proxy doesn't hold anything we could call a reference to the real service. But the point of that reference in the traditional diagram is to convey that the proxy has the ability to pass calls through to the real service, and our WCF proxy does exactly that.&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/5119957131131393001-8044135123775114903?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/8044135123775114903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-for-net-part.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/8044135123775114903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/8044135123775114903'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/toms-patterns-cheat-sheet-for-net-part.html' title='Tom’s Patterns Cheat Sheet for .NET – Part 1: Template Method, Strategy, Observer, Adapter, Proxy Patterns'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_-6lCnWdTHH4/SZnnkyMakdI/AAAAAAAAAFg/U82iQdY9fVQ/s72-c/templatemethod.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-11314870823832186</id><published>2009-02-09T19:05:00.000-08:00</published><updated>2009-02-09T19:14:54.362-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='YAGNI'/><title type='text'>Best YAGNI quote ever</title><content type='html'>I just wish I could say it was mine.  This gem is from Russ Olsen's &lt;a href="http://www.amazon.com/Design-Patterns-Ruby-Addison-Wesley-Professional/dp/0321490452/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1234235575&amp;amp;sr=8-1"&gt;Design Patterns in Ruby&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Look at it this way: Barring a sharp blow to the head, as you stand here today you are as dumb as you ever will be. We are all learning, getting smarter every day. This is especially true in software projects. You can be sure that you will have a better grasp of the requirements, technology, and design of any software system that you work on at the end of the project than at the beginning. Whenever you put in a feature before you really need it, you are guilty of programming while stupid; if you wait until you really need the thing, you are likely to have a better understanding of what you need to do and how you should go about doing it. &lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5119957131131393001-11314870823832186?l=computing-tombarreras.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://computing-tombarreras.blogspot.com/feeds/11314870823832186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/i-just-wish-i-could-say-it-was-mine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/11314870823832186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5119957131131393001/posts/default/11314870823832186'/><link rel='alternate' type='text/html' href='http://computing-tombarreras.blogspot.com/2009/02/i-just-wish-i-could-say-it-was-mine.html' title='Best YAGNI quote ever'/><author><name>eTom</name><uri>http://www.blogger.com/profile/04027990099226709014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='http://bp1.blogger.com/_-6lCnWdTHH4/R3s-xda_neI/AAAAAAAAAAM/Wpt9epDC92Q/S220/Marvin+da+Martian.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5119957131131393001.post-5174065225123638389</id><published>2009-02-06T19:43:00.001-08:00</published><updated>2009-02-08T21:39:47.079-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Enum'/><category scheme='http://www.blogger.com/atom/ns#' term='Generics'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Fast enumeration to string conversion in C#</title><content type='html'>&lt;title&gt;Code&lt;/title&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9414"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9415"   &gt;&lt;span designtimesp="9416" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="9417"  style="font-family:Arial;"&gt;.NET's ToString() behavior on enumeration values is nice,  translating the value to the string representation of it that we see in code, as  this simple console application shows:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9418"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="9420"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9421"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9422"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9423"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; System;&lt;o:p designtimesp="9424"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9425"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9426"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9427"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; System.Collections.Generic;&lt;o:p designtimesp="9428"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9429"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9430"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9431"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; System.Linq;&lt;o:p designtimesp="9432"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9433"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9434"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9435"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; System.Text;&lt;o:p designtimesp="9436"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9437"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9438"  &gt;&lt;o:p designtimesp="9439"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9440"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9441"   &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9442"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; FastEnumToString&lt;o:p designtimesp="9443"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9444"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9445"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9446"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9447"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9448"  &gt;&lt;span style="" designtimesp="9449"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9450"  style="color:blue;"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="9451"&gt;Program&lt;o:p designtimesp="9452"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9453"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9454"  &gt;&lt;span style="" designtimesp="9455"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9456"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9457"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9458"  &gt;&lt;span style="" designtimesp="9459"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9460"  style="color:blue;"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="9461"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="9462"&gt;Color&lt;o:p designtimesp="9463"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9464"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9465"  &gt;&lt;span style="" designtimesp="9466"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9467"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9468"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9469"  &gt;&lt;span style="" designtimesp="9470"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Red,&lt;o:p designtimesp="9471"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9472"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9473"  &gt;&lt;span style="" designtimesp="9474"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;White,&lt;o:p designtimesp="9475"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9476"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9477"  &gt;&lt;span style="" designtimesp="9478"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Blue,&lt;o:p designtimesp="9479"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9480"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9481"  &gt;&lt;span style="" designtimesp="9482"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Green&lt;o:p designtimesp="9483"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9484"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9485"  &gt;&lt;span style="" designtimesp="9486"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="9487"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9488"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9489"  &gt;&lt;o:p designtimesp="9490"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9491"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9492"  &gt;&lt;span style="" designtimesp="9493"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9494"  style="color:blue;"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="9495"  style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span designtimesp="9496"  style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;o:p designtimesp="9497"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9498"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9499"  &gt;&lt;span style="" designtimesp="9500"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9501"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9502"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9503"  &gt;&lt;span style="" designtimesp="9504"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9505"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(43, 145, 175);" designtimesp="9506"&gt;Color&lt;/span&gt;.Red);&lt;o:p designtimesp="9507"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9508"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9509"  &gt;&lt;span style="" designtimesp="9510"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9511"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(43, 145, 175);" designtimesp="9512"&gt;Color&lt;/span&gt;.White);&lt;o:p designtimesp="9513"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9514"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9515"  &gt;&lt;span style="" designtimesp="9516"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9517"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(43, 145, 175);" designtimesp="9518"&gt;Color&lt;/span&gt;.Blue);&lt;o:p designtimesp="9519"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9520"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9521"  &gt;&lt;span style="" designtimesp="9522"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9523"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(43, 145, 175);" designtimesp="9524"&gt;Color&lt;/span&gt;.Green);&lt;o:p designtimesp="9525"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9526"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9527"  &gt;&lt;o:p designtimesp="9528"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9529"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9530"  &gt;&lt;span style="" designtimesp="9531"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9532"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;.ReadLine();&lt;o:p designtimesp="9533"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9534"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9535"  &gt;&lt;span style="" designtimesp="9536"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="9537"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9538"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9539"  &gt;&lt;span style="" designtimesp="9540"&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="9541"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="9542"&gt;&lt;span style="line-height: 115%;font-family:'Courier New';font-size:10;" designtimesp="9543"  &gt;&lt;span designtimesp="9419" style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9545"   &gt;&lt;span designtimesp="9546" style="color: rgb(0, 0, 0);font-family:Arial;" &gt;which  yields this output:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p designtimesp="9544"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Arial';font-size:10;color:blue;" designtimesp="9545"   &gt;Red&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p designtimesp="9544"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Arial';font-size:10;color:blue;" designtimesp="9545"   &gt;White&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p designtimesp="9544"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Arial';font-size:10;color:blue;" designtimesp="9545"   &gt;Blue&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p designtimesp="9544"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Arial';font-size:10;color:blue;" designtimesp="9545"   &gt;Green&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p designtimesp="9547"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9548"   &gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p designtimesp="9551"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9552"   &gt;&lt;span designtimesp="9553" style="color: rgb(0, 0, 0);font-family:Arial;" &gt;But  Microsoft has &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/16c1xs4z.aspx#Mtps_DropDownFilterText" designtimesp="9554"&gt;&lt;span designtimesp="9555" style="color: rgb(0, 0, 0);font-family:Arial;" &gt;this  warning&lt;/span&gt;&lt;/a&gt;&lt;span designtimesp="9556"  style="font-family:Arial;"&gt;&lt;span designtimesp="9557" style="color: rgb(0, 0, 0);"&gt; about Enum.ToString:&lt;br /&gt;&lt;strong designtimesp="9559"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;blockquote designtimesp="9562"&gt; &lt;p designtimesp="9563"&gt;&lt;span designtimesp="9564" style="color: rgb(0, 0, 0);font-family:Arial;font-size:100%;"  &gt;Because this method searches metadata tables, it heavily  uses system resources and can impede performance.&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9565"&gt;&lt;span designtimesp="9566" style="color: rgb(0, 0, 0);font-family:Arial;font-size:100%;"  &gt;.NET uses  reflection to look up the string representation of the enumeration when  .ToString() is called. This simple test application shows the performance of the  call on my laptop:&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="9567"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9568"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9569"   &gt;using&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9570"  &gt;&lt;span designtimesp="9571" style="color: rgb(0, 0, 0);"&gt; System;&lt;o:p designtimesp="9572"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9573"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9574"  &gt;&lt;o:p designtimesp="9575"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9577"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9578"   &gt;namespace&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9579"  &gt;&lt;span designtimesp="9580" style="color: rgb(0, 0, 0);"&gt;  FastEnumToString&lt;o:p designtimesp="9581"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9582"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9583"  &gt;&lt;span designtimesp="9584" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9585"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9586"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9587"  &gt;&lt;span style="" designtimesp="9588"&gt;&lt;span designtimesp="9589" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9590"  style="color:blue;"&gt;class&lt;/span&gt;&lt;span designtimesp="9591" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9592"&gt;Program&lt;o:p designtimesp="9593"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9594"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9595"  &gt;&lt;span designtimesp="9596" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9597"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9598"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9599"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9600"  &gt;&lt;span style="" designtimesp="9601"&gt;&lt;span designtimesp="9602" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9603"  style="color:blue;"&gt;public&lt;/span&gt;&lt;span designtimesp="9604" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span designtimesp="9605"  style="color:blue;"&gt;enum&lt;/span&gt;&lt;span designtimesp="9606" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9607"&gt;Color&lt;o:p designtimesp="9608"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9609"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9610"  &gt;&lt;span designtimesp="9611" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9612"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9613"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9614"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9615"  &gt;&lt;span designtimesp="9616" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9617"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Red,&lt;o:p designtimesp="9618"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9619"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9620"  &gt;&lt;span designtimesp="9621" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9622"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;White,&lt;o:p designtimesp="9623"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9624"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9625"  &gt;&lt;span designtimesp="9626" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9627"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Blue,&lt;o:p designtimesp="9628"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9629"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9630"  &gt;&lt;span designtimesp="9631" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9632"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Green&lt;o:p designtimesp="9633"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9634"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9635"  &gt;&lt;span designtimesp="9636" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9638"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9639"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9640"  &gt;&lt;o:p designtimesp="9641"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9643"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9644"  &gt;&lt;span style="" designtimesp="9645"&gt;&lt;span designtimesp="9646" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9647"  style="color:blue;"&gt;static&lt;/span&gt;&lt;span designtimesp="9648" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span designtimesp="9649"  style="color:blue;"&gt;void&lt;/span&gt;&lt;span designtimesp="9650" style="color: rgb(0, 0, 0);"&gt;  Main(&lt;/span&gt;&lt;span designtimesp="9651"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="9652" style="color: rgb(0, 0, 0);"&gt;[] args)&lt;o:p designtimesp="9653"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9654"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9655"  &gt;&lt;span designtimesp="9656" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9657"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9658"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9659"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9660"  &gt;&lt;span style="" designtimesp="9661"&gt;&lt;span designtimesp="9662" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9663"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="9664" style="color: rgb(0, 0, 0);"&gt; start = &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9665"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="9666" style="color: rgb(0, 0, 0);"&gt;.Now;&lt;o:p designtimesp="9667"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9668"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9669"  &gt;&lt;span style="" designtimesp="9670"&gt;&lt;span designtimesp="9671" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9672"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="9673" style="color: rgb(0, 0, 0);"&gt; rand = &lt;/span&gt;&lt;span designtimesp="9674"  style="color:blue;"&gt;new&lt;/span&gt;&lt;span designtimesp="9675" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9676"&gt;Random&lt;/span&gt;&lt;span designtimesp="9677" style="color: rgb(0, 0, 0);"&gt;();&lt;o:p designtimesp="9678"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9679"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9680"  &gt;&lt;o:p designtimesp="9681"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9683"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9684"  &gt;&lt;span style="" designtimesp="9685"&gt;&lt;span designtimesp="9686" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9687"  style="color:blue;"&gt;for&lt;/span&gt;&lt;span designtimesp="9688" style="color: rgb(0, 0, 0);"&gt; (&lt;/span&gt;&lt;span designtimesp="9689"  style="color:blue;"&gt;int&lt;/span&gt;&lt;span designtimesp="9690" style="color: rgb(0, 0, 0);"&gt; i = 1; i  &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9692"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9693"  &gt;&lt;span designtimesp="9694" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9695"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9696"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9697"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9698"  &gt;&lt;span style="" designtimesp="9699"&gt;&lt;span designtimesp="9700" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9701"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="9702" style="color: rgb(0, 0, 0);"&gt; color = (&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9703"&gt;Color&lt;/span&gt;&lt;span designtimesp="9704" style="color: rgb(0, 0, 0);"&gt;)rand.Next(4);&lt;o:p designtimesp="9705"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9706"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9707"  &gt;&lt;span style="" designtimesp="9708"&gt;&lt;span designtimesp="9709" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9710"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="9711" style="color: rgb(0, 0, 0);"&gt; str = color.ToString();&lt;o:p designtimesp="9712"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9713"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9714"  &gt;&lt;span designtimesp="9715" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9716"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9717"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9718"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9719"  &gt;&lt;o:p designtimesp="9720"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9722"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9723"  &gt;&lt;span designtimesp="9724" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9725"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="" designtimesp="9726"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9727"&gt;TimeSpan&lt;/span&gt;&lt;span designtimesp="9728" style="color: rgb(0, 0, 0);"&gt; span = &lt;/span&gt;&lt;span designtimesp="9729"  style="color:blue;"&gt;new&lt;/span&gt;&lt;span designtimesp="9730" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9731"&gt;TimeSpan&lt;/span&gt;&lt;span designtimesp="9732" style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9733"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="9734" style="color: rgb(0, 0, 0);"&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="9735"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9736"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9737"  &gt;&lt;span style="" designtimesp="9738"&gt;&lt;span designtimesp="9739" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9740"&gt;Console&lt;/span&gt;&lt;span designtimesp="9741" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9742"&gt;"ToString() took "&lt;/span&gt;&lt;span designtimesp="9743" style="color: rgb(0, 0, 0);"&gt; + span.ToString());&lt;o:p designtimesp="9744"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9745"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9746"  &gt;&lt;o:p designtimesp="9747"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9749"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9750"  &gt;&lt;span style="" designtimesp="9751"&gt;&lt;span designtimesp="9752" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9753"&gt;Console&lt;/span&gt;&lt;span designtimesp="9754" style="color: rgb(0, 0, 0);"&gt;.ReadLine();&lt;o:p designtimesp="9755"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9756"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9757"  &gt;&lt;span designtimesp="9758" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9759"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9760"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9761"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9762"  &gt;&lt;span designtimesp="9763" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9764"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9765"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9766"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9767"  &gt;&lt;span designtimesp="9768" style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9766"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9772"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:100%;" &gt;Which yields:&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9772"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9772"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;ToString() took 00:00:02.7460000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9772"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9773"&gt;&lt;span designtimesp="9774" style="color: rgb(0, 0, 0);font-size:100%;" &gt;So it took 2.746  seconds to convert an enum to a string a million times. This may not seem too  bad, but in a recent profiling of the application I work on we found that  calling Enum.ToString() was one of the most significant performance problems in  the system. We found that we were calling Enum.ToString() 50,000 times just to  bring up our login screen! And that was just the tip of the iceburg -  Enum.ToString() is being called literally millions of times in any given user  session, adding noticable lag times to many operations in the system.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9775"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9777"&gt;&lt;span designtimesp="9778" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;br /&gt;So what to do about  it? The first thing that comes to mind, from traditional object oriented  programming, is to override the ToString() method of the System.Enum class (the  C# enum keyword being mere syntax sure on top of System.Enum), but attempts to  do so are greeted with the compilation error, "Cannot derive from special class  System.Enum".&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9779"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9781"&gt;&lt;span designtimesp="9782" style="color: rgb(0, 0, 0);font-size:100%;" &gt;Another simple  solution would be to use .NET 3.5 extension methods:&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9783"&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="9785"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9786"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9787"   &gt;using&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9788"  &gt;&lt;span designtimesp="9789" style="color: rgb(0, 0, 0);"&gt; System;&lt;o:p designtimesp="9790"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9791"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9792"  &gt;&lt;o:p designtimesp="9793"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9795"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="9796"   &gt;namespace&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9797"  &gt;&lt;span designtimesp="9798" style="color: rgb(0, 0, 0);"&gt;  FastEnumToString&lt;o:p designtimesp="9799"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9800"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9801"  &gt;&lt;span designtimesp="9802" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="9803"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9804"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9805"  &gt;&lt;span style="" designtimesp="9806"&gt;&lt;span designtimesp="9807" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9808"  style="color:blue;"&gt;public&lt;/span&gt;&lt;span designtimesp="9809" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span designtimesp="9810"  style="color:blue;"&gt;enum&lt;/span&gt;&lt;span designtimesp="9811" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9812"&gt;Color&lt;o:p designtimesp="9813"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9814"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9815"  &gt;&lt;span designtimesp="9816" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9817"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9818"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9819"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9820"  &gt;&lt;span designtimesp="9821" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9822"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Red,&lt;o:p designtimesp="9823"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9824"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9825"  &gt;&lt;span designtimesp="9826" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9827"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;White,&lt;o:p designtimesp="9828"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9829"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9830"  &gt;&lt;span designtimesp="9831" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9832"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Blue,&lt;o:p designtimesp="9833"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9834"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9835"  &gt;&lt;span designtimesp="9836" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9837"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;Green&lt;o:p designtimesp="9838"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9839"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9840"  &gt;&lt;span designtimesp="9841" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9842"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9843"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9844"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9845"  &gt;&lt;span designtimesp="9846" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9847"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;o:p designtimesp="9848"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9849"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9850"  &gt;&lt;span style="" designtimesp="9851"&gt;&lt;span designtimesp="9852" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9853"  style="color:blue;"&gt;static&lt;/span&gt;&lt;span designtimesp="9854" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span designtimesp="9855"  style="color:blue;"&gt;class&lt;/span&gt;&lt;span designtimesp="9856" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9857"&gt;Extensions&lt;o:p designtimesp="9858"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9859"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9860"  &gt;&lt;span designtimesp="9861" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9862"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9863"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9864"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9865"  &gt;&lt;span style="" designtimesp="9866"&gt;&lt;span designtimesp="9867" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9868"  style="color:blue;"&gt;public&lt;/span&gt;&lt;span designtimesp="9869" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span designtimesp="9870"  style="color:blue;"&gt;static&lt;/span&gt;&lt;span designtimesp="9871" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span designtimesp="9872"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="9873" style="color: rgb(0, 0, 0);"&gt; FastToString(&lt;/span&gt;&lt;span designtimesp="9874"  style="color:blue;"&gt;this&lt;/span&gt;&lt;span designtimesp="9875" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9876"&gt;Color&lt;/span&gt;&lt;span designtimesp="9877" style="color: rgb(0, 0, 0);"&gt; color)&lt;o:p designtimesp="9878"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9879"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9880"  &gt;&lt;span designtimesp="9881" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9882"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9883"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9884"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9885"  &gt;&lt;span style="" designtimesp="9886"&gt;&lt;span designtimesp="9887" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9888"  style="color:blue;"&gt;switch&lt;/span&gt;&lt;span designtimesp="9889" style="color: rgb(0, 0, 0);"&gt; (color)&lt;o:p designtimesp="9890"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9891"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9892"  &gt;&lt;span designtimesp="9893" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9894"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="9895"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9896"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9897"  &gt;&lt;span style="" designtimesp="9898"&gt;&lt;span designtimesp="9899" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9900"  style="color:blue;"&gt;case&lt;/span&gt;&lt;span designtimesp="9901" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9902"&gt;Color&lt;/span&gt;&lt;span designtimesp="9903" style="color: rgb(0, 0, 0);"&gt;.Red:  &lt;/span&gt;&lt;span designtimesp="9904"  style="color:blue;"&gt;return&lt;/span&gt;&lt;span designtimesp="9905" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9906"&gt;"Red"&lt;/span&gt;&lt;span designtimesp="9907" style="color: rgb(0, 0, 0);"&gt;;  &lt;/span&gt;&lt;span designtimesp="9908"  style="color:blue;"&gt;break&lt;/span&gt;&lt;span designtimesp="9909" style="color: rgb(0, 0, 0);"&gt;;&lt;o:p designtimesp="9910"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9911"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9912"  &gt;&lt;span style="" designtimesp="9913"&gt;&lt;span designtimesp="9914" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9915"  style="color:blue;"&gt;case&lt;/span&gt;&lt;span designtimesp="9916" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9917"&gt;Color&lt;/span&gt;&lt;span designtimesp="9918" style="color: rgb(0, 0, 0);"&gt;.Green:  &lt;/span&gt;&lt;span designtimesp="9919"  style="color:blue;"&gt;return&lt;/span&gt;&lt;span designtimesp="9920" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9921"&gt;"Green"&lt;/span&gt;&lt;span designtimesp="9922" style="color: rgb(0, 0, 0);"&gt;;  &lt;/span&gt;&lt;span designtimesp="9923"  style="color:blue;"&gt;break&lt;/span&gt;&lt;span designtimesp="9924" style="color: rgb(0, 0, 0);"&gt;;&lt;o:p designtimesp="9925"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9926"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9927"  &gt;&lt;span style="" designtimesp="9928"&gt;&lt;span designtimesp="9929" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9930"  style="color:blue;"&gt;case&lt;/span&gt;&lt;span designtimesp="9931" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9932"&gt;Color&lt;/span&gt;&lt;span designtimesp="9933" style="color: rgb(0, 0, 0);"&gt;.Blue:  &lt;/span&gt;&lt;span designtimesp="9934"  style="color:blue;"&gt;return&lt;/span&gt;&lt;span designtimesp="9935" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9936"&gt;"Blue"&lt;/span&gt;&lt;span designtimesp="9937" style="color: rgb(0, 0, 0);"&gt;;  &lt;/span&gt;&lt;span designtimesp="9938"  style="color:blue;"&gt;break&lt;/span&gt;&lt;span designtimesp="9939" style="color: rgb(0, 0, 0);"&gt;;&lt;o:p designtimesp="9940"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9941"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9942"  &gt;&lt;span style="" designtimesp="9943"&gt;&lt;span designtimesp="9944" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9945"  style="color:blue;"&gt;case&lt;/span&gt;&lt;span designtimesp="9946" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9947"&gt;Color&lt;/span&gt;&lt;span designtimesp="9948" style="color: rgb(0, 0, 0);"&gt;.White:  &lt;/span&gt;&lt;span designtimesp="9949"  style="color:blue;"&gt;return&lt;/span&gt;&lt;span designtimesp="9950" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9951"&gt;"White"&lt;/span&gt;&lt;span designtimesp="9952" style="color: rgb(0, 0, 0);"&gt;;  &lt;/span&gt;&lt;span designtimesp="9953"  style="color:blue;"&gt;break&lt;/span&gt;&lt;span designtimesp="9954" style="color: rgb(0, 0, 0);"&gt;;&lt;o:p designtimesp="9955"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9956"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9957"  &gt;&lt;span style="" designtimesp="9958"&gt;&lt;span designtimesp="9959" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9960"  style="color:blue;"&gt;default&lt;/span&gt;&lt;span designtimesp="9961" style="color: rgb(0, 0, 0);"&gt;: &lt;/span&gt;&lt;span designtimesp="9962"  style="color:blue;"&gt;return&lt;/span&gt;&lt;span designtimesp="9963" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="9964"&gt;"Undefined"&lt;/span&gt;&lt;span designtimesp="9965" style="color: rgb(0, 0, 0);"&gt;; &lt;/span&gt;&lt;span designtimesp="9966"  style="color:blue;"&gt;break&lt;/span&gt;&lt;span designtimesp="9967" style="color: rgb(0, 0, 0);"&gt;;&lt;o:p designtimesp="9968"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9969"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9970"  &gt;&lt;span designtimesp="9971" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9972"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9973"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9974"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9975"  &gt;&lt;span designtimesp="9976" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9977"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9978"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9979"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9980"  &gt;&lt;span designtimesp="9981" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9982"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="9983"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9984"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9985"  &gt;&lt;o:p designtimesp="9986"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9988"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9989"  &gt;&lt;span style="" designtimesp="9990"&gt;&lt;span designtimesp="9991" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="9992"  style="color:blue;"&gt;class&lt;/span&gt;&lt;span designtimesp="9993" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="9994"&gt;Program&lt;o:p designtimesp="9995"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="9996"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="9997"  &gt;&lt;span designtimesp="9998" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="9999"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="10000"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10001"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10002"  &gt;&lt;span style="" designtimesp="10003"&gt;&lt;span designtimesp="10004" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10005"  style="color:blue;"&gt;static&lt;/span&gt;&lt;span designtimesp="10006" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span designtimesp="10007"  style="color:blue;"&gt;void&lt;/span&gt;&lt;span designtimesp="10008" style="color: rgb(0, 0, 0);"&gt;  Main(&lt;/span&gt;&lt;span designtimesp="10009"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="10010" style="color: rgb(0, 0, 0);"&gt;[] args)&lt;o:p designtimesp="10011"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10012"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10013"  &gt;&lt;span designtimesp="10014" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10015"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="10016"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10017"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10018"  &gt;&lt;span style="" designtimesp="10019"&gt;&lt;span designtimesp="10020" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10021"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="10022" style="color: rgb(0, 0, 0);"&gt; start = &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10023"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="10024" style="color: rgb(0, 0, 0);"&gt;.Now;&lt;o:p designtimesp="10025"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10026"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10027"  &gt;&lt;span style="" designtimesp="10028"&gt;&lt;span designtimesp="10029" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10030"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="10031" style="color: rgb(0, 0, 0);"&gt; rand = &lt;/span&gt;&lt;span designtimesp="10032"  style="color:blue;"&gt;new&lt;/span&gt;&lt;span designtimesp="10033" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10034"&gt;Random&lt;/span&gt;&lt;span designtimesp="10035" style="color: rgb(0, 0, 0);"&gt;();&lt;o:p designtimesp="10036"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10037"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10038"  &gt;&lt;o:p designtimesp="10039"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10041"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10042"  &gt;&lt;span style="" designtimesp="10043"&gt;&lt;span designtimesp="10044" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10045"  style="color:blue;"&gt;for&lt;/span&gt;&lt;span designtimesp="10046" style="color: rgb(0, 0, 0);"&gt; (&lt;/span&gt;&lt;span designtimesp="10047"  style="color:blue;"&gt;int&lt;/span&gt;&lt;span designtimesp="10048" style="color: rgb(0, 0, 0);"&gt; i = 1;  i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10050"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10051"  &gt;&lt;span designtimesp="10052" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10053"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="10054"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10055"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10056"  &gt;&lt;span style="" designtimesp="10057"&gt;&lt;span designtimesp="10058" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10059"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="10060" style="color: rgb(0, 0, 0);"&gt; color = (&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10061"&gt;Color&lt;/span&gt;&lt;span designtimesp="10062" style="color: rgb(0, 0, 0);"&gt;)rand.Next(4);&lt;o:p designtimesp="10063"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10064"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10065"  &gt;&lt;span style="" designtimesp="10066"&gt;&lt;span designtimesp="10067" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10068"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="10069" style="color: rgb(0, 0, 0);"&gt; str = color.ToString();&lt;o:p designtimesp="10070"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10071"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10072"  &gt;&lt;span designtimesp="10073" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10074"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="10075"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10076"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10077"  &gt;&lt;o:p designtimesp="10078"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10080"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10081"  &gt;&lt;span style="" designtimesp="10082"&gt;&lt;span designtimesp="10083" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10084"&gt;TimeSpan&lt;/span&gt;&lt;span designtimesp="10085" style="color: rgb(0, 0, 0);"&gt; span = &lt;/span&gt;&lt;span designtimesp="10086"  style="color:blue;"&gt;new&lt;/span&gt;&lt;span designtimesp="10087" style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10088"&gt;TimeSpan&lt;/span&gt;&lt;span designtimesp="10089" style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10090"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="10091" style="color: rgb(0, 0, 0);"&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="10092"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10093"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10094"  &gt;&lt;span style="" designtimesp="10095"&gt;&lt;span designtimesp="10096" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10097"&gt;Console&lt;/span&gt;&lt;span designtimesp="10098" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="10099"&gt;"ToString() took "&lt;/span&gt;&lt;span designtimesp="10100" style="color: rgb(0, 0, 0);"&gt; + span.ToString());&lt;o:p designtimesp="10101"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10102"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10103"  &gt;&lt;o:p designtimesp="10104"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10106"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10107"  &gt;&lt;span designtimesp="10108" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10109"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;start =  &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10110"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="10111" style="color: rgb(0, 0, 0);"&gt;.Now;&lt;o:p designtimesp="10112"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10113"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10114"  &gt;&lt;span style="" designtimesp="10115"&gt;&lt;span designtimesp="10116" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10117"  style="color:blue;"&gt;for&lt;/span&gt;&lt;span designtimesp="10118" style="color: rgb(0, 0, 0);"&gt; (&lt;/span&gt;&lt;span designtimesp="10119"  style="color:blue;"&gt;int&lt;/span&gt;&lt;span designtimesp="10120" style="color: rgb(0, 0, 0);"&gt; i = 1;  i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10122"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10123"  &gt;&lt;span designtimesp="10124" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10125"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;o:p designtimesp="10126"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10127"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10128"  &gt;&lt;span style="" designtimesp="10129"&gt;&lt;span designtimesp="10130" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10131"  style="color:blue;"&gt;var&lt;/span&gt;&lt;span designtimesp="10132" style="color: rgb(0, 0, 0);"&gt; color = (&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10133"&gt;Color&lt;/span&gt;&lt;span designtimesp="10134" style="color: rgb(0, 0, 0);"&gt;)rand.Next(4);&lt;o:p designtimesp="10135"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10136"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10137"  &gt;&lt;span style="" designtimesp="10138"&gt;&lt;span designtimesp="10139" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10140"  style="color:blue;"&gt;string&lt;/span&gt;&lt;span designtimesp="10141" style="color: rgb(0, 0, 0);"&gt; str = color.FastToString();&lt;o:p designtimesp="10142"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10143"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10144"  &gt;&lt;span designtimesp="10145" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10146"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="10147"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10148"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10149"  &gt;&lt;o:p designtimesp="10150"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10152"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10153"  &gt;&lt;span designtimesp="10154" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10155"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;span =  &lt;/span&gt;&lt;span designtimesp="10156"  style="color:blue;"&gt;new&lt;/span&gt;&lt;span designtimesp="10157" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10158"&gt;TimeSpan&lt;/span&gt;&lt;span designtimesp="10159" style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10160"&gt;DateTime&lt;/span&gt;&lt;span designtimesp="10161" style="color: rgb(0, 0, 0);"&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="10162"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10163"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10164"  &gt;&lt;span style="" designtimesp="10165"&gt;&lt;span designtimesp="10166" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10167"&gt;Console&lt;/span&gt;&lt;span designtimesp="10168" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);" designtimesp="10169"&gt;"FastToString() took "&lt;/span&gt;&lt;span designtimesp="10170" style="color: rgb(0, 0, 0);"&gt; + span.ToString());&lt;o:p designtimesp="10171"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10172"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10173"  &gt;&lt;o:p designtimesp="10174"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10176"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10177"  &gt;&lt;span style="" designtimesp="10178"&gt;&lt;span designtimesp="10179" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10180"&gt;Console&lt;/span&gt;&lt;span designtimesp="10181" style="color: rgb(0, 0, 0);"&gt;.ReadLine();&lt;o:p designtimesp="10182"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10183"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10184"  &gt;&lt;span designtimesp="10185" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10186"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="10187"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10188"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10189"  &gt;&lt;span designtimesp="10190" style="color: rgb(0, 0, 0);"&gt;&lt;span style="" designtimesp="10191"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;o:p designtimesp="10192"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10193"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10194"  &gt;&lt;span designtimesp="10195" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10196"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10197"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p designtimesp="10198"&gt;&lt;span designtimesp="10199" style="color: rgb(0, 0, 0);"&gt; The result is  much faster:&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10197"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;ToString()  took 00:00:02.5550000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10197"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:blue;"&gt;FastToString() took  00:00:00.0680000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p designtimesp="10201"&gt; &lt;/o:p&gt;&lt;/span&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10204"&gt;&lt;span designtimesp="10205" style="color: rgb(0, 0, 0);font-size:100%;" &gt;0.068 seconds for a million FastToString()  calls, faster by a factor of 38. This is great, but the extension method code  written above is tedious and error prone. When the next developer comes along  and adds another color to the enumeration, he or she will have to remember to  add it to the extension method. And any typo in the enumeration strings could  produce difficult to find bugs down the road, especially if the code is using  Enum.Parse to convert the string back into a Color.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10206"&gt;&lt;span designtimesp="10207" style="color: rgb(0, 0, 0);font-size:100%;" &gt;This would be a good use of CodeDOM or some  other code generation technique to automatically generate the extension methods,  but here's another solution that can be coded directly:&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt; &lt;/span&gt;&lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="10209"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10210"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10211"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10212"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; System;&lt;o:p designtimesp="10213"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10214"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10215"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10216"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; System.Globalization;&lt;o:p designtimesp="10217"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10218"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10219"  &gt;&lt;o:p designtimesp="10220"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10221"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10222"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10223"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; FastEnumToString&lt;o:p designtimesp="10224"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10225"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10226"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10227"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10228"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10229"  &gt;&lt;span style="" designtimesp="10230"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10231"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10232"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10233"&gt;Color&lt;o:p designtimesp="10234"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10235"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10236"  &gt;&lt;span style="" designtimesp="10237"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10238"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10239"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10240"  &gt;&lt;span style="" designtimesp="10241"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Red,&lt;o:p designtimesp="10242"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10243"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10244"  &gt;&lt;span style="" designtimesp="10245"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;White,&lt;o:p designtimesp="10246"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10247"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10248"  &gt;&lt;span style="" designtimesp="10249"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Blue,&lt;o:p designtimesp="10250"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10251"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10252"  &gt;&lt;span style="" designtimesp="10253"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Green&lt;o:p designtimesp="10254"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10255"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10256"  &gt;&lt;span style="" designtimesp="10257"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10258"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10259"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10260"  &gt;&lt;o:p designtimesp="10261"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10262"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10263"  &gt;&lt;span style="" designtimesp="10264"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10265"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10266"  style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10267"&gt;Extensions&lt;o:p designtimesp="10268"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10269"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10270"  &gt;&lt;span style="" designtimesp="10271"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10272"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10273"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10274"  &gt;&lt;span style="" designtimesp="10275"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10276"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10277"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10278"  style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10279"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt;&lt;o:p designtimesp="10280"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10281"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10282"  &gt;&lt;span style="" designtimesp="10283"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10284"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10285"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10286"  &gt;&lt;span style="" designtimesp="10287"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10288"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10289"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10290"  style="color:blue;"&gt;string&lt;/span&gt;[] _strings;&lt;o:p designtimesp="10291"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10292"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10293"  &gt;&lt;o:p designtimesp="10294"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10295"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10296"  &gt;&lt;span style="" designtimesp="10297"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10298"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; EnumStrings()&lt;o:p designtimesp="10299"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10300"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10301"  &gt;&lt;span style="" designtimesp="10302"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10303"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10304"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10305"  &gt;&lt;span style="" designtimesp="10306"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10307"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; (&lt;span designtimesp="10308"  style="color:blue;"&gt;typeof&lt;/span&gt;(T).IsEnum)&lt;o:p designtimesp="10309"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10310"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10311"  &gt;&lt;span style="" designtimesp="10312"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="" designtimesp="10313"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10314"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10315"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10316"  &gt;&lt;span style="" designtimesp="10317"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;_strings = &lt;span designtimesp="10318"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span designtimesp="10319"  style="color:blue;"&gt;string&lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);" designtimesp="10320"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="10321"  style="color:blue;"&gt;typeof&lt;/span&gt;(T)).Length];&lt;o:p designtimesp="10322"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10323"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10324"  &gt;&lt;o:p designtimesp="10325"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10326"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10327"  &gt;&lt;span style="" designtimesp="10328"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10329"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; (System.&lt;span style="color: rgb(43, 145, 175);" designtimesp="10330"&gt;Enum&lt;/span&gt; value &lt;span designtimesp="10331"  style="color:blue;"&gt;in&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10332"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="10333"  style="color:blue;"&gt;typeof&lt;/span&gt;(T)))&lt;o:p designtimesp="10334"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10335"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10336"  &gt;&lt;span style="" designtimesp="10337"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10338"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10339"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10340"  &gt;&lt;span style="" designtimesp="10341"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;_strings[((&lt;span style="color: rgb(43, 145, 175);" designtimesp="10342"&gt;IConvertible&lt;/span&gt;)value).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10343"&gt;CultureInfo&lt;/span&gt;.InvariantCulture)] =  value.ToString();&lt;o:p designtimesp="10344"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10345"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10346"  &gt;&lt;span style="" designtimesp="10347"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10348"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10349"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10350"  &gt;&lt;span style="" designtimesp="10351"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10352"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10353"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10354"  &gt;&lt;span style="" designtimesp="10355"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10356"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;else&lt;o:p designtimesp="10357"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10358"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10359"  &gt;&lt;span style="" designtimesp="10360"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10361"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10362"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10363"  &gt;&lt;span style="" designtimesp="10364"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10365"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10366"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10367"&gt;Exception&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);" designtimesp="10368"&gt;"Generic type must be an enumeration"&lt;/span&gt;);&lt;o:p designtimesp="10369"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10370"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10371"  &gt;&lt;span style="" designtimesp="10372"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10373"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10374"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10375"  &gt;&lt;span style="" designtimesp="10376"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10377"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10378"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10379"  &gt;&lt;o:p designtimesp="10380"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10381"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10382"  &gt;&lt;span style="" designtimesp="10383"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10384"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10385"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10386"  style="color:blue;"&gt;string&lt;/span&gt; GetEnumString(&lt;span designtimesp="10387"  style="color:blue;"&gt;int&lt;/span&gt; enumValue)&lt;o:p designtimesp="10388"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10389"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10390"  &gt;&lt;span style="" designtimesp="10391"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10392"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10393"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10394"  &gt;&lt;span style="" designtimesp="10395"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10396"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; _strings[enumValue];&lt;o:p designtimesp="10397"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10398"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10399"  &gt;&lt;span style="" designtimesp="10400"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10401"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10402"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10403"  &gt;&lt;span style="" designtimesp="10404"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10405"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10406"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10407"  &gt;&lt;o:p designtimesp="10408"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10409"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10410"  &gt;&lt;span style="" designtimesp="10411"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10412"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10413"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10414"  style="color:blue;"&gt;string&lt;/span&gt; FastToString(&lt;span designtimesp="10415"  style="color:blue;"&gt;this&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10416"&gt;Color&lt;/span&gt; color)&lt;o:p designtimesp="10417"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10418"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10419"  &gt;&lt;span style="" designtimesp="10420"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10421"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10422"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10423"  &gt;&lt;span style="" designtimesp="10424"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10425"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10426"&gt;EnumStrings&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10427"&gt;Color&lt;/span&gt;&gt;.GetEnumString((&lt;span designtimesp="10428"  style="color:blue;"&gt;int&lt;/span&gt;)color);&lt;o:p designtimesp="10429"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10430"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10431"  &gt;&lt;span style="" designtimesp="10432"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10433"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10434"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10435"  &gt;&lt;span style="" designtimesp="10436"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10437"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10438"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10439"  &gt;&lt;o:p designtimesp="10440"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10441"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10442"  &gt;&lt;span style="" designtimesp="10443"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10444"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10445"&gt;Program&lt;o:p designtimesp="10446"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10447"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10448"  &gt;&lt;span style="" designtimesp="10449"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10450"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10451"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10452"  &gt;&lt;span style="" designtimesp="10453"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10454"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10455"  style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span designtimesp="10456"  style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;o:p designtimesp="10457"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10458"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10459"  &gt;&lt;span style="" designtimesp="10460"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10461"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10462"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10463"  &gt;&lt;span style="" designtimesp="10464"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10465"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; start = &lt;span style="color: rgb(43, 145, 175);" designtimesp="10466"&gt;DateTime&lt;/span&gt;.Now;&lt;o:p designtimesp="10467"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10468"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10469"  &gt;&lt;span style="" designtimesp="10470"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10471"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; rand = &lt;span designtimesp="10472"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10473"&gt;Random&lt;/span&gt;();&lt;o:p designtimesp="10474"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10475"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10476"  &gt;&lt;o:p designtimesp="10477"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10478"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10479"  &gt;&lt;span style="" designtimesp="10480"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10481"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; (&lt;span designtimesp="10482"  style="color:blue;"&gt;int&lt;/span&gt; i = 1; i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10484"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10485"  &gt;&lt;span style="" designtimesp="10486"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10487"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10488"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10489"  &gt;&lt;span style="" designtimesp="10490"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10491"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; color = (&lt;span style="color: rgb(43, 145, 175);" designtimesp="10492"&gt;Color&lt;/span&gt;)rand.Next(4);&lt;o:p designtimesp="10493"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10494"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10495"  &gt;&lt;span style="" designtimesp="10496"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10497"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; str = color.ToString();&lt;o:p designtimesp="10498"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10499"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10500"  &gt;&lt;span style="" designtimesp="10501"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10502"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10503"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10504"  &gt;&lt;o:p designtimesp="10505"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10506"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10507"  &gt;&lt;span style="" designtimesp="10508"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10509"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;TimeSpan&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; span = &lt;span designtimesp="10510"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10511"&gt;TimeSpan&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10512"&gt;DateTime&lt;/span&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="10513"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10514"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10515"  &gt;&lt;span style="" designtimesp="10516"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10517"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);" designtimesp="10518"&gt;"ToString() took "&lt;/span&gt; + span.ToString());&lt;o:p designtimesp="10519"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10520"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10521"  &gt;&lt;o:p designtimesp="10522"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10523"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10524"  &gt;&lt;span style="" designtimesp="10525"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;start = &lt;span style="color: rgb(43, 145, 175);" designtimesp="10526"&gt;DateTime&lt;/span&gt;.Now;&lt;o:p designtimesp="10527"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10528"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10529"  &gt;&lt;span style="" designtimesp="10530"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10531"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; (&lt;span designtimesp="10532"  style="color:blue;"&gt;int&lt;/span&gt; i = 1; i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10534"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10535"  &gt;&lt;span style="" designtimesp="10536"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10537"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10538"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10539"  &gt;&lt;span style="" designtimesp="10540"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10541"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; color = (&lt;span style="color: rgb(43, 145, 175);" designtimesp="10542"&gt;Color&lt;/span&gt;)rand.Next(4);&lt;o:p designtimesp="10543"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10544"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10545"  &gt;&lt;span style="" designtimesp="10546"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10547"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; str = color.FastToString();&lt;o:p designtimesp="10548"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10549"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10550"  &gt;&lt;span style="" designtimesp="10551"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10552"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10553"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10554"  &gt;&lt;o:p designtimesp="10555"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10556"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10557"  &gt;&lt;span style="" designtimesp="10558"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;span = &lt;span designtimesp="10559"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10560"&gt;TimeSpan&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10561"&gt;DateTime&lt;/span&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="10562"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10563"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10564"  &gt;&lt;span style="" designtimesp="10565"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10566"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);" designtimesp="10567"&gt;"FastToString() took "&lt;/span&gt; + span.ToString());&lt;o:p designtimesp="10568"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10569"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10570"  &gt;&lt;o:p designtimesp="10571"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10572"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10573"  &gt;&lt;span style="" designtimesp="10574"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10575"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;.ReadLine();&lt;o:p designtimesp="10576"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10577"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10578"  &gt;&lt;span style="" designtimesp="10579"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10580"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10581"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10582"  &gt;&lt;span style="" designtimesp="10583"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10584"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10585"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10586"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10587"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10588"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p designtimesp="10589"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; The results are quite good, roughly the same as the  hardcoded solution:&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10588"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;ToString() took 00:00:02.6770000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10588"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;FastToString() took 00:00:00.0580000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10590"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;The idea is  simple: we want to store the string descriptions of the enumerations in an array  the first time they are accessed, so we have our FastToString extension method  read them out of a static class that builds the array in its constructor. We use  a generic static class because that's a convenient way to get the compiler to  create a separate array for each type of enumeration.&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10594"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;Note the  "&lt;span designtimesp="10595"  style="color:blue;"&gt;if&lt;/span&gt; (&lt;span designtimesp="10596"  style="color:blue;"&gt;typeof&lt;/span&gt;(T).IsEnum)&lt;o:p designtimesp="10597"&gt;&lt;/o:p&gt;" line in the constructor. We would dearly have liked  to restrict the generic type with a &lt;span designtimesp="10598" style="color: rgb(0, 0, 255);"&gt;&lt;span designtimesp="10599" style="color: rgb(0, 0, 255);"&gt;where&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10600"&gt; T :  System.Enum &lt;span designtimesp="10601"&gt;constraint. That would have  allowed us to write a single generic extension method for all  enumerations:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10604"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10605"  &gt;&lt;span style="" designtimesp="10606"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10607"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt; &lt;span designtimesp="10608"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10609"  style="color:blue;"&gt;string&lt;/span&gt; FastToString&amp;lt;T&amp;gt;&lt;t&gt;(&lt;span designtimesp="10610"  style="color:blue;"&gt;this&lt;/span&gt; T value) &lt;span designtimesp="10611"  style="color:blue;"&gt;where&lt;/span&gt; T : System.Enum&lt;o:p designtimesp="10612"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10613"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10614"  &gt;&lt;span style="" designtimesp="10615"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;{&lt;o:p designtimesp="10616"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10617"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10618"  &gt;&lt;span style="" designtimesp="10619"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10620"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10621"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt;.GetEnumString((&lt;span designtimesp="10622"  style="color:blue;"&gt;int&lt;/span&gt;)value);&lt;o:p designtimesp="10623"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10624"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 115%;font-family:'Courier New';font-size:10;" designtimesp="10625"  &gt;&lt;span style="" designtimesp="10626"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10627"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10602"&gt;&lt;span designtimesp="10603"&gt;but when we  try it we're greeted again with our friendly compiler error, "Constraint cannot  be special class 'System.Enum'". Because of this I'm forced to enforce the  generic type with a runtime exception (and it &lt;em designtimesp="10628"&gt;is&lt;/em&gt; a  &lt;em designtimesp="10629"&gt;runtime&lt;/em&gt; exception - try replacing &amp;lt;Color&amp;gt;  with &amp;lt;string&amp;gt; in the FastToString method and see what happens). This  exception makes EnumStrings&amp;lt;T&amp;gt;&lt;t&gt; a dangerous class to use, which is why I've  made it a rare example of a private, nested class. It is essentially an un-type  safe class, because the compiler is unable to enforce its type-safe use.&lt;br /&gt;&lt;/t&gt;&lt;/string&gt;&lt;/color&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10631"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10632"&gt;&lt;span designtimesp="10633"&gt;So each developer  that creates an enumeration will need to add a corresponding FastToString  overload for their enumeration, but at least they don't have to add or maintain  the error-prone switch statement.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10634"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10635"&gt;&lt;span designtimesp="10636"&gt;One more thing to  mention before continuing: we can't remove the "where T : System.Enum"  constraint in the FastToString overload above because there's no guarantee that  the input parameter "value" can be cast to an int, but we can do any of these  things:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10637"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10638"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10639"  &gt;&lt;span style="" designtimesp="10640"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10641"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span designtimesp="10642"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10643"  style="color:blue;"&gt;string&lt;/span&gt; FastToString&amp;lt;T&amp;gt;&lt;t&gt;(&lt;span designtimesp="10644"  style="color:blue;"&gt;this&lt;/span&gt; T value) &lt;span designtimesp="10645"  style="color:blue;"&gt;where&lt;/span&gt; T : &lt;span style="color: rgb(43, 145, 175);" designtimesp="10646"&gt;IConvertible&lt;o:p designtimesp="10647"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10648"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10649"  &gt;&lt;span style="" designtimesp="10650"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;{&lt;o:p designtimesp="10651"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10652"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10653"  &gt;&lt;span style="" designtimesp="10654"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10655"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10656"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt;.GetEnumString(((&lt;span style="color: rgb(43, 145, 175);" designtimesp="10657"&gt;IConvertible&lt;/span&gt;)value).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10658"&gt;CultureInfo&lt;/span&gt;.InvariantCulture));&lt;o:p designtimesp="10659"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10660"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10661"  &gt;&lt;span style="" designtimesp="10662"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;}&lt;o:p designtimesp="10663"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10664"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10665"  &gt;&lt;o:p designtimesp="10666"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10667"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10668"  &gt;&lt;span style="" designtimesp="10669"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10670"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span designtimesp="10671"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10672"  style="color:blue;"&gt;string&lt;/span&gt; FastToString&amp;lt;T&amp;gt;&lt;t&gt;(&lt;span designtimesp="10673"  style="color:blue;"&gt;this&lt;/span&gt; System.&lt;span style="color: rgb(43, 145, 175);" designtimesp="10674"&gt;Enum&lt;/span&gt; value)&lt;o:p designtimesp="10675"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10676"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10677"  &gt;&lt;span style="" designtimesp="10678"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;{&lt;o:p designtimesp="10679"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10680"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10681"  &gt;&lt;span style="" designtimesp="10682"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10683"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10684"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt;.GetEnumString(((&lt;span style="color: rgb(43, 145, 175);" designtimesp="10685"&gt;IConvertible&lt;/span&gt;)value).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10686"&gt;CultureInfo&lt;/span&gt;.InvariantCulture));&lt;o:p designtimesp="10687"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10688"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10689"  &gt;&lt;span style="" designtimesp="10690"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;}&lt;o:p designtimesp="10691"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10692"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10693"  &gt;&lt;o:p designtimesp="10694"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10695"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10696"  &gt;&lt;span style="" designtimesp="10697"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10698"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span designtimesp="10699"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10700"  style="color:blue;"&gt;string&lt;/span&gt; FastToString&amp;lt;T&amp;gt;&lt;t&gt;(&lt;span designtimesp="10701"  style="color:blue;"&gt;this&lt;/span&gt; &lt;span designtimesp="10702"  style="color:blue;"&gt;int&lt;/span&gt; value)&lt;o:p designtimesp="10703"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10704"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10705"  &gt;&lt;span style="" designtimesp="10706"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;{&lt;o:p designtimesp="10707"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10708"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10709"  &gt;&lt;span style="" designtimesp="10710"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10711"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10712"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt;.GetEnumString(value);&lt;o:p designtimesp="10713"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10714"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10715"  &gt;&lt;span style="" designtimesp="10716"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10637"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10717"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10718"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10719"&gt;The client calls for these look like  this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10720"&gt; &lt;/span&gt;&lt;/span&gt;&lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="10721"&gt; &lt;p designtimesp="10722"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10723" style="color: rgb(0, 0, 255);"&gt;&lt;span designtimesp="10724" style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10725"&gt; str  = color.FastToString&lt;&lt;/span&gt;&lt;span designtimesp="10726" style="color: rgb(43, 145, 175);"&gt;&lt;span designtimesp="10727" style="color: rgb(43, 145, 175);"&gt;Color&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10728"&gt;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10729"&gt;&lt;span designtimesp="10730"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p designtimesp="10731"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10729"&gt;&lt;span designtimesp="10732" style="color: rgb(0, 0, 255);"&gt;&lt;span designtimesp="10733" style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10734"&gt; str  = ((&lt;/span&gt;&lt;span designtimesp="10735" style="color: rgb(43, 145, 175);"&gt;&lt;span designtimesp="10736" style="color: rgb(43, 145, 175);"&gt;Enum&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10737"&gt;)color).FastToString&lt;&lt;/span&gt;&lt;span designtimesp="10738" style="color: rgb(43, 145, 175);"&gt;&lt;span designtimesp="10739" style="color: rgb(43, 145, 175);"&gt;Color&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10740"&gt;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10729"&gt;&lt;span designtimesp="10741"&gt;&lt;span designtimesp="10742"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p designtimesp="10743"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10729"&gt;&lt;span designtimesp="10741"&gt;&lt;span designtimesp="10744" style="color: rgb(0, 0, 255);"&gt;&lt;span designtimesp="10745" style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10746"&gt; str  = ((&lt;/span&gt;&lt;span designtimesp="10747" style="color: rgb(0, 0, 255);"&gt;&lt;span designtimesp="10748" style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10749"&gt;)color).FastToString&lt;&lt;/span&gt;&lt;span designtimesp="10750" style="color: rgb(43, 145, 175);"&gt;&lt;span designtimesp="10751" style="color: rgb(43, 145, 175);"&gt;Color&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10752"&gt;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt; &lt;/span&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10754"&gt;Which result in the following timings:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;ToString() took 00:00:02.6130000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;FastToString() took 00:00:00.0700000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;FastToString&amp;lt;T&amp;gt;&lt;t&gt;(this T value) took  00:00:00.3820000&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;FastToString&amp;lt;T&amp;gt;&lt;t&gt;(this Enum value) took  00:00:00.3690000&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10753"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span style="color: rgb(0, 128, 255);"&gt;FastToString&amp;lt;T&amp;gt;&lt;t&gt;(this int value) took  00:00:00.0710000&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10758"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10759"&gt;The two overloads that involve use of IConvertible  are about 5 times slower than the one that doesn't. This is most likely due to  the boxing that takes places when casting the enum to IConvertible. It is,  however, still 7 times faster than ToString().&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10760"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10761"&gt;But I wouldn't recommend using any of the overloads  that include the generic parameter, because they expose EnumString&amp;lt;T&amp;gt;&lt;t&gt;'s  type-unsafety to the caller. Because of .NET's current limitation against using  System.Enum as a base class constraint on T, there's no way for us to prevent  the client from calling FastString&amp;lt;Color&amp;gt; on some other enumeration type,  or from making a (5).FastString&amp;lt;Color&amp;gt; call, or even from calling  FastString&amp;lt;string&amp;gt;.&lt;/string&gt;&lt;/color&gt;&lt;/color&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10762"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10763"&gt;The final thing to note is that the above code won't  work on enumerations that don't use the default enumeration value - integer  mapping, e.g.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10764"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10765"  &gt;&lt;span style="" designtimesp="10766"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10767"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &lt;span designtimesp="10768"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10769"&gt;Color&lt;o:p designtimesp="10770"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10771"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10772"  &gt;&lt;span style="" designtimesp="10773"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;{&lt;o:p designtimesp="10774"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10775"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10776"  &gt;&lt;span style="" designtimesp="10777"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Red = 2,&lt;o:p designtimesp="10778"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10779"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10780"  &gt;&lt;span style="" designtimesp="10781"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;White = 4,&lt;o:p designtimesp="10782"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10783"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10784"  &gt;&lt;span style="" designtimesp="10785"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Blue = 8,&lt;o:p designtimesp="10786"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10787"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10788"  &gt;&lt;span style="" designtimesp="10789"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;Green = 16&lt;o:p designtimesp="10790"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10791"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 115%;font-family:'Courier New';font-size:10;" designtimesp="10792"  &gt;&lt;span style="" designtimesp="10793"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;}&lt;o:p designtimesp="10794"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10795"&gt; &lt;/p&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10796"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10797"&gt;&lt;span designtimesp="10798"&gt;even this is  legal:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10802"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10803"  &gt;&lt;span style="" designtimesp="10804"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10805"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10806"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10807"&gt;Color&lt;o:p designtimesp="10808"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10809"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10810"  &gt;&lt;span style="" designtimesp="10811"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10812"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10813"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10814"  &gt;&lt;span style="" designtimesp="10815"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Red = -1,&lt;o:p designtimesp="10816"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10817"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10818"  &gt;&lt;span style="" designtimesp="10819"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;White = -1,&lt;o:p designtimesp="10820"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10821"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10822"  &gt;&lt;span style="" designtimesp="10823"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Blue = -1,&lt;o:p designtimesp="10824"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10825"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10826"  &gt;&lt;span style="" designtimesp="10827"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Green = -1&lt;o:p designtimesp="10828"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10829"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 115%;font-family:'Courier New';font-size:10;" designtimesp="10830"  &gt;&lt;span style="" designtimesp="10831"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 10pt;" designtimesp="10832"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);font-size:100%;" &gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;One way to  handle these cases is to use a Dictionary to store the enumeration-string  mapping rather than an array. We would expect dictionary lookups to be slower  than array lookups, so we'll continue to use arrays for the "standard"  enumerations.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;" designtimesp="10833"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10834"  &gt;&lt;o:p designtimesp="10835"&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10836"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10834"  &gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10837"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10838"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; System;&lt;o:p designtimesp="10839"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10834"  &gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10840"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10841"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10842"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; System.Globalization;&lt;o:p designtimesp="10843"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10844"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10845"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10846"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; System.Collections.Generic;&lt;o:p designtimesp="10847"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10848"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10849"  &gt;&lt;o:p designtimesp="10850"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10851"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;" designtimesp="10852"   &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;namespace&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10853"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; FastEnumToString&lt;o:p designtimesp="10854"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10855"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10856"  &gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10857"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10858"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10859"  &gt;&lt;span style="" designtimesp="10860"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10861"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10862"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10863"&gt;Color&lt;o:p designtimesp="10864"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10865"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10866"  &gt;&lt;span style="" designtimesp="10867"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10868"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10869"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10870"  &gt;&lt;span style="" designtimesp="10871"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Red = -1,&lt;o:p designtimesp="10872"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10873"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10874"  &gt;&lt;span style="" designtimesp="10875"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;White = -1,&lt;o:p designtimesp="10876"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10877"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10878"  &gt;&lt;span style="" designtimesp="10879"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Blue = -1,&lt;o:p designtimesp="10880"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10881"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10882"  &gt;&lt;span style="" designtimesp="10883"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Green = -1&lt;o:p designtimesp="10884"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10885"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10886"  &gt;&lt;span style="" designtimesp="10887"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="10888"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10889"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10890"  &gt;&lt;o:p designtimesp="10891"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10892"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10893"  &gt;&lt;span style="" designtimesp="10894"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10895"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10896"  style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10897"&gt;State&lt;o:p designtimesp="10898"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10899"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10900"  &gt;&lt;span style="" designtimesp="10901"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10902"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10903"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10904"  &gt;&lt;span style="" designtimesp="10905"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Oregon,&lt;o:p designtimesp="10906"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10907"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10908"  &gt;&lt;span style="" designtimesp="10909"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Washington,&lt;o:p designtimesp="10910"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10911"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10912"  &gt;&lt;span style="" designtimesp="10913"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;California,&lt;o:p designtimesp="10914"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10915"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10916"  &gt;&lt;span style="" designtimesp="10917"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Idaho&lt;o:p designtimesp="10918"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10919"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10920"  &gt;&lt;span style="" designtimesp="10921"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="10922"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10923"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10924"  &gt;&lt;o:p designtimesp="10925"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10926"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10927"  &gt;&lt;span style="" designtimesp="10928"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10929"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10930"  style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10931"&gt;Extensions&lt;o:p designtimesp="10932"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10933"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10934"  &gt;&lt;span style="" designtimesp="10935"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10936"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10937"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10938"  &gt;&lt;span style="" designtimesp="10939"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10940"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10941"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10942"  style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10943"&gt;EnumStrings&lt;/span&gt;&amp;lt;T&amp;gt;&lt;t&gt; &lt;o:p designtimesp="10944"&gt;&lt;/o:p&gt;&lt;/t&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10945"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10946"  &gt;&lt;span style="" designtimesp="10947"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10948"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10949"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10950"  &gt;&lt;span style="" designtimesp="10951"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10952"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10953"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10954"  style="color:blue;"&gt;string&lt;/span&gt;[] _strings = &lt;span designtimesp="10955"  style="color:blue;"&gt;null&lt;/span&gt;;&lt;o:p designtimesp="10956"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10957"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10958"  &gt;&lt;span style="" designtimesp="10959"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10960"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10961"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10962"&gt;Dictionary&lt;/span&gt;&lt;&lt;span designtimesp="10963"  style="color:blue;"&gt;int&lt;/span&gt;, &lt;span designtimesp="10964"  style="color:blue;"&gt;string&lt;/span&gt;&gt; _stringDictionary = &lt;span designtimesp="10965"  style="color:blue;"&gt;null&lt;/span&gt;;&lt;o:p designtimesp="10966"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10967"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10968"  &gt;&lt;o:p designtimesp="10969"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10970"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10971"  &gt;&lt;span style="" designtimesp="10972"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10973"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="10974"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="10975"  style="color:blue;"&gt;bool&lt;/span&gt; IsStandardSequence(&lt;span style="color: rgb(43, 145, 175);" designtimesp="10976"&gt;Array&lt;/span&gt; values)&lt;o:p designtimesp="10977"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10978"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10979"  &gt;&lt;span style="" designtimesp="10980"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="10981"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10982"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10983"  &gt;&lt;span style="" designtimesp="10984"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10985"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;List&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&lt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10986"&gt;Enum&lt;/span&gt;&gt; valuesList = &lt;span designtimesp="10987"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="10988"&gt;List&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="10989"&gt;Enum&lt;/span&gt;&gt;();&lt;o:p designtimesp="10990"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10991"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10992"  &gt;&lt;span style="" designtimesp="10993"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10994"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (&lt;span style="color: rgb(43, 145, 175);" designtimesp="10995"&gt;Enum&lt;/span&gt; value &lt;span designtimesp="10996"  style="color:blue;"&gt;in&lt;/span&gt; values)&lt;o:p designtimesp="10997"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="10998"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="10999"  &gt;&lt;span style="" designtimesp="11000"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11001"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11002"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11003"  &gt;&lt;span style="" designtimesp="11004"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;valuesList.Add(value);&lt;o:p designtimesp="11005"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11006"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11007"  &gt;&lt;span style="" designtimesp="11008"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11009"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11010"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11011"  &gt;&lt;o:p designtimesp="11012"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11013"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11014"  &gt;&lt;span style="" designtimesp="11015"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;valuesList.Sort();&lt;o:p designtimesp="11016"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11017"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11018"  &gt;&lt;span style="" designtimesp="11019"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11020"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (&lt;span designtimesp="11021"  style="color:blue;"&gt;int&lt;/span&gt; i = 0; i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11023"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11024"  &gt;&lt;span style="" designtimesp="11025"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11026"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11027"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11028"  &gt;&lt;span style="" designtimesp="11029"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11030"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (((&lt;span style="color: rgb(43, 145, 175);" designtimesp="11031"&gt;IConvertible&lt;/span&gt;)valuesList[i]).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="11032"&gt;CultureInfo&lt;/span&gt;.InvariantCulture)  != i)&lt;o:p designtimesp="11033"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11034"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11035"  &gt;&lt;span style="" designtimesp="11036"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11037"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11038"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11039"  &gt;&lt;span style="" designtimesp="11040"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11041"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11042"  style="color:blue;"&gt;false&lt;/span&gt;;&lt;o:p designtimesp="11043"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11044"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11045"  &gt;&lt;span style="" designtimesp="11046"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11047"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11048"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11049"  &gt;&lt;span style="" designtimesp="11050"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11051"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11052"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11053"  &gt;&lt;span style="" designtimesp="11054"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11055"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11056"  style="color:blue;"&gt;true&lt;/span&gt;;&lt;o:p designtimesp="11057"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11058"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11059"  &gt;&lt;span style="" designtimesp="11060"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11061"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11062"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11063"  &gt;&lt;o:p designtimesp="11064"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11065"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11066"  &gt;&lt;span style="" designtimesp="11067"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11068"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; EnumStrings()&lt;o:p designtimesp="11069"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11070"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11071"  &gt;&lt;span style="" designtimesp="11072"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11073"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11074"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11075"  &gt;&lt;span style="" designtimesp="11076"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11077"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (&lt;span designtimesp="11078"  style="color:blue;"&gt;typeof&lt;/span&gt;(T).IsEnum)&lt;o:p designtimesp="11079"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11080"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11081"  &gt;&lt;span style="" designtimesp="11082"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11083"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11084"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11085"  &gt;&lt;span style="" designtimesp="11086"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11087"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (IsStandardSequence(&lt;span style="color: rgb(43, 145, 175);" designtimesp="11088"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="11089"  style="color:blue;"&gt;typeof&lt;/span&gt;(T))))&lt;o:p designtimesp="11090"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11091"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11092"  &gt;&lt;span style="" designtimesp="11093"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11094"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11095"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11096"  &gt;&lt;span style="" designtimesp="11097"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;_strings = &lt;span designtimesp="11098"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span designtimesp="11099"  style="color:blue;"&gt;string&lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);" designtimesp="11100"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="11101"  style="color:blue;"&gt;typeof&lt;/span&gt;(T)).Length];&lt;o:p designtimesp="11102"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11103"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11104"  &gt;&lt;o:p designtimesp="11105"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11106"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11107"  &gt;&lt;span style="" designtimesp="11108"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="" designtimesp="11109"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11110"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (System.&lt;span style="color: rgb(43, 145, 175);" designtimesp="11111"&gt;Enum&lt;/span&gt; value &lt;span designtimesp="11112"  style="color:blue;"&gt;in&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11113"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="11114"  style="color:blue;"&gt;typeof&lt;/span&gt;(T)))&lt;o:p designtimesp="11115"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11116"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11117"  &gt;&lt;span style="" designtimesp="11118"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11119"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11120"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11121"  &gt;&lt;span style="" designtimesp="11122"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;_strings[((&lt;span style="color: rgb(43, 145, 175);" designtimesp="11123"&gt;IConvertible&lt;/span&gt;)value).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="11124"&gt;CultureInfo&lt;/span&gt;.InvariantCulture)] =  value.ToString();&lt;o:p designtimesp="11125"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11126"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11127"  &gt;&lt;span style="" designtimesp="11128"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11129"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11130"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11131"  &gt;&lt;span style="" designtimesp="11132"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="" designtimesp="11133"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11134"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11135"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11136"  &gt;&lt;span style="" designtimesp="11137"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11138"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;else&lt;o:p designtimesp="11139"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11140"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11141"  &gt;&lt;span style="" designtimesp="11142"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11143"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11144"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11145"  &gt;&lt;span style="" designtimesp="11146"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;_stringDictionary = &lt;span designtimesp="11147"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11148"&gt;Dictionary&lt;/span&gt;&lt;&lt;span designtimesp="11149"  style="color:blue;"&gt;int&lt;/span&gt;, &lt;span designtimesp="11150"  style="color:blue;"&gt;string&lt;/span&gt;&gt;();&lt;o:p designtimesp="11151"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11152"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11153"  &gt;&lt;o:p designtimesp="11154"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11155"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11156"  &gt;&lt;span style="" designtimesp="11157"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11158"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;foreach&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (System.&lt;span style="color: rgb(43, 145, 175);" designtimesp="11159"&gt;Enum&lt;/span&gt; value &lt;span designtimesp="11160"  style="color:blue;"&gt;in&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11161"&gt;Enum&lt;/span&gt;.GetValues(&lt;span designtimesp="11162"  style="color:blue;"&gt;typeof&lt;/span&gt;(T)))&lt;o:p designtimesp="11163"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11164"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11165"  &gt;&lt;span style="" designtimesp="11166"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11167"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11168"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11169"  &gt;&lt;span style="" designtimesp="11170"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11171"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; valueAsInt = ((&lt;span style="color: rgb(43, 145, 175);" designtimesp="11172"&gt;IConvertible&lt;/span&gt;)value).ToInt32(&lt;span style="color: rgb(43, 145, 175);" designtimesp="11173"&gt;CultureInfo&lt;/span&gt;.InvariantCulture);&lt;o:p designtimesp="11174"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11175"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11176"  &gt;&lt;span style="" designtimesp="11177"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11178"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;  (!_stringDictionary.ContainsKey(valueAsInt))&lt;o:p designtimesp="11179"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11180"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11181"  &gt;&lt;span style="" designtimesp="11182"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;_stringDictionary.Add(valueAsInt, value.ToString());&lt;o:p designtimesp="11183"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11184"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11185"  &gt;&lt;span style="" designtimesp="11186"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11187"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11188"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11189"  &gt;&lt;span style="" designtimesp="11190"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11191"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11192"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11193"  &gt;&lt;span style="" designtimesp="11194"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11195"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11196"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11197"  &gt;&lt;span style="" designtimesp="11198"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11199"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;else&lt;o:p designtimesp="11200"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11201"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11202"  &gt;&lt;span style="" designtimesp="11203"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11204"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11205"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11206"  &gt;&lt;span style="" designtimesp="11207"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11208"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;throw&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11209"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11210"&gt;Exception&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);" designtimesp="11211"&gt;"Generic type must be an enumeration"&lt;/span&gt;);&lt;o:p designtimesp="11212"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11213"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11214"  &gt;&lt;span style="" designtimesp="11215"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11216"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11217"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11218"  &gt;&lt;span style="" designtimesp="11219"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11220"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11221"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11222"  &gt;&lt;o:p designtimesp="11223"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11224"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11225"  &gt;&lt;span style="" designtimesp="11226"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11227"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11228"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="11229"  style="color:blue;"&gt;string&lt;/span&gt; GetEnumString(&lt;span designtimesp="11230"  style="color:blue;"&gt;int&lt;/span&gt; value)&lt;o:p designtimesp="11231"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11232"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11233"  &gt;&lt;span style="" designtimesp="11234"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11235"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11236"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11237"  &gt;&lt;span style="" designtimesp="11238"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11239"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; description;&lt;o:p designtimesp="11240"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11241"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11242"  &gt;&lt;o:p designtimesp="11243"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11244"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11245"  &gt;&lt;span style="" designtimesp="11246"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11247"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;if&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (_strings != &lt;span designtimesp="11248"  style="color:blue;"&gt;null&lt;/span&gt;)&lt;o:p designtimesp="11249"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11250"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11251"  &gt;&lt;span style="" designtimesp="11252"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11253"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11254"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11255"  &gt;&lt;span style="" designtimesp="11256"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;description = _strings[(&lt;span designtimesp="11257"  style="color:blue;"&gt;int&lt;/span&gt;)value];&lt;o:p designtimesp="11258"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11259"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11260"  &gt;&lt;span style="" designtimesp="11261"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11262"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11263"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11264"  &gt;&lt;span style="" designtimesp="11265"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11266"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;else&lt;o:p designtimesp="11267"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11268"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11269"  &gt;&lt;span style="" designtimesp="11270"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11271"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11272"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11273"  &gt;&lt;span style="" designtimesp="11274"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="" designtimesp="11275"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;_stringDictionary.TryGetValue(value,  &lt;span designtimesp="11276"  style="color:blue;"&gt;out&lt;/span&gt; description);&lt;o:p designtimesp="11277"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11278"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11279"  &gt;&lt;span style="" designtimesp="11280"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11281"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11282"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11283"  &gt;&lt;span style="" designtimesp="11284"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11285"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; description;&lt;o:p designtimesp="11286"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11287"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11288"  &gt;&lt;span style="" designtimesp="11289"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11290"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11291"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11292"  &gt;&lt;span style="" designtimesp="11293"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11294"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11295"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11296"  &gt;&lt;o:p designtimesp="11297"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11298"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11299"  &gt;&lt;span style="" designtimesp="11300"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11301"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11302"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="11303"  style="color:blue;"&gt;string&lt;/span&gt; FastToString(&lt;span designtimesp="11304"  style="color:blue;"&gt;this&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11305"&gt;Color&lt;/span&gt; color)&lt;o:p designtimesp="11306"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11307"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11308"  &gt;&lt;span style="" designtimesp="11309"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11310"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11311"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11312"  &gt;&lt;span style="" designtimesp="11313"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11314"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11315"&gt;EnumStrings&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="11316"&gt;Color&lt;/span&gt;&gt;.GetEnumString((&lt;span designtimesp="11317"  style="color:blue;"&gt;int&lt;/span&gt;)color);&lt;o:p designtimesp="11318"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11319"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11320"  &gt;&lt;span style="" designtimesp="11321"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11322"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11323"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11324"  &gt;&lt;o:p designtimesp="11325"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11326"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11327"  &gt;&lt;span style="" designtimesp="11328"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11329"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11330"  style="color:blue;"&gt;static&lt;/span&gt; &lt;span designtimesp="11331"  style="color:blue;"&gt;string&lt;/span&gt; FastToString(&lt;span designtimesp="11332"  style="color:blue;"&gt;this&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11333"&gt;State&lt;/span&gt; state)&lt;o:p designtimesp="11334"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11335"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11336"  &gt;&lt;span style="" designtimesp="11337"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11338"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11339"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11340"  &gt;&lt;span style="" designtimesp="11341"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11342"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11343"&gt;EnumStrings&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="11344"&gt;State&lt;/span&gt;&gt;.GetEnumString((&lt;span designtimesp="11345"  style="color:blue;"&gt;int&lt;/span&gt;)state);&lt;o:p designtimesp="11346"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11347"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11348"  &gt;&lt;span style="" designtimesp="11349"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11350"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11351"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11352"  &gt;&lt;span style="" designtimesp="11353"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11354"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11355"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11356"  &gt;&lt;o:p designtimesp="11357"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11358"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11359"  &gt;&lt;span style="" designtimesp="11360"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11361"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11362"&gt;Program&lt;o:p designtimesp="11363"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11364"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11365"  &gt;&lt;span style="" designtimesp="11366"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11367"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11368"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11369"  &gt;&lt;span style="" designtimesp="11370"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11371"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; &lt;span designtimesp="11372"  style="color:blue;"&gt;void&lt;/span&gt; Main(&lt;span designtimesp="11373"  style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;o:p designtimesp="11374"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11375"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11376"  &gt;&lt;span style="" designtimesp="11377"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11378"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11379"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11380"  &gt;&lt;span style="" designtimesp="11381"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11382"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; start = &lt;span style="color: rgb(43, 145, 175);" designtimesp="11383"&gt;DateTime&lt;/span&gt;.Now;&lt;o:p designtimesp="11384"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11385"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11386"  &gt;&lt;span style="" designtimesp="11387"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11388"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; rand = &lt;span designtimesp="11389"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11390"&gt;Random&lt;/span&gt;();&lt;o:p designtimesp="11391"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11392"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11393"  &gt;&lt;o:p designtimesp="11394"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11395"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11396"  &gt;&lt;span style="" designtimesp="11397"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11398"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; (&lt;span designtimesp="11399"  style="color:blue;"&gt;int&lt;/span&gt; i = 1; i &lt; 1000000; i++)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11401"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11402"  &gt;&lt;span style="" designtimesp="11403"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;{&lt;o:p designtimesp="11404"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11405"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11406"  &gt;&lt;span style="" designtimesp="11407"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11408"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; color = (&lt;span style="color: rgb(43, 145, 175);" designtimesp="11409"&gt;Color&lt;/span&gt;)rand.Next(4);&lt;o:p designtimesp="11410"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11411"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11412"  &gt;&lt;span style="" designtimesp="11413"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="11414"  style="color:blue;"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; str = color.ToString();&lt;o:p designtimesp="11415"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11416"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11417"  &gt;&lt;span style="" designtimesp="11418"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;}&lt;o:p designtimesp="11419"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11420"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11421"  &gt;&lt;o:p designtimesp="11422"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11423"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11424"  &gt;&lt;span style="" designtimesp="11425"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="11426"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;TimeSpan&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt; span = &lt;span designtimesp="11427"  style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);" designtimesp="11428"&gt;TimeSpan&lt;/span&gt;(&lt;span style="color: rgb(43, 145, 175);" designtimesp="11429"&gt;DateTime&lt;/span&gt;.Now.Ticks - start.Ticks);&lt;o:p designtimesp="11430"&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal;" designtimesp="11431"&gt;&lt;span style=";font-family:'Courier New';font-size:10;" designtimesp="11432"  &gt;&lt;span style="" designtimesp="11433"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);" designtimesp="11434"&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;Console&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span designtimesp="10208" style="color: rgb(0, 0, 0);"&gt;&lt;span designtimesp="10800"&gt;&lt;span designtimesp="10801"&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);" designtimesp="11435"&gt;"ToString() took "&lt;/span&gt; + span.ToStri
