<?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:blogger='http://schemas.google.com/blogger/2008' 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-7745129748420905494</id><updated>2024-10-11T12:52:02.530-07:00</updated><category term="ajax"/><category term="flash"/><category term="json"/><category term="web2.0"/><category term="actionscript"/><category term="asp.net"/><category term="cache"/><category term="http"/><category term="iframe"/><category term="javascript"/><category term="open source"/><category term="samples"/><category term="tag"/><category term="xml"/><category term="Custom fields"/><category term="Sidebar"/><category term="UGC"/><category term="Wordpress"/><category term="access stdev"/><category term="ajax cache request response pragma"/><category term="anger"/><category term="array"/><category term="bbc"/><category term="browser"/><category term="browser ie internet explorer firefox request browsercapabilities"/><category term="business objects"/><category term="cnn"/><category term="code samples"/><category term="codeplex"/><category term="control toolkit"/><category term="controls"/><category term="data transfer"/><category term="dataset"/><category term="debug"/><category term="delicious"/><category term="demo"/><category term="design"/><category term="development process"/><category term="digg"/><category term="download unlocker"/><category term="duration length minutes seconds formatting"/><category term="emotions"/><category term="experts exchange"/><category term="file to unlock"/><category term="file unlocker"/><category term="foundation server"/><category term="google"/><category term="group by"/><category term="how to unlock a file"/><category term="how to unlock file"/><category term="html"/><category term="http handler"/><category term="iis"/><category term="internet explorer"/><category term="intuition"/><category term="loadvars"/><category term="meta"/><category term="microsoft"/><category term="news"/><category term="news industry"/><category term="normal distribution"/><category term="object"/><category term="page"/><category term="parsing"/><category term="permalink"/><category term="player"/><category term="pooled stdev"/><category term="quartile"/><category term="query string"/><category term="relax"/><category term="server"/><category term="sitemap"/><category term="sniffer"/><category term="split"/><category term="standard deviation"/><category term="standard deviations"/><category term="stdev"/><category term="stdev formula"/><category term="stdev sql"/><category term="stdev stdevp"/><category term="stdevp"/><category term="string"/><category term="stumbleupon"/><category term="sumproduct"/><category term="tags"/><category term="team foundation"/><category term="team foundation server"/><category term="team foundation server 2005"/><category term="team foundation server 2008"/><category term="url"/><category term="variance"/><category term="vba stdev"/><category term="video"/><category term="visual studio"/><category term="xmldocument"/><category term="z score"/><title type='text'>Blood Sweat and Bugs</title><subtitle type='html'>Programming tips, cool tools, code samples, tutorials, and just stuff I like.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-7831737859945982879</id><published>2009-01-29T06:18:00.000-08:00</published><updated>2009-01-29T06:18:00.200-08:00</updated><title type='text'>How to: Define Value Equality for a Type (C# Programming)</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div class=&#39;introduction&#39;&gt;&lt;p&gt; When you define a class or struct, you&lt;br /&gt;decide whether it makes sense to create a custom definition of value&lt;br /&gt;equality (or equivalence) for the type. Typically, you implement value&lt;br /&gt;equality when objects of the type are expected to be added to a&lt;br /&gt;collection of some sort, or when their primary purpose is to store a&lt;br /&gt;set of fields or properties. You can base your definition of value&lt;br /&gt;equality on a comparison of all the fields and properties in the type,&lt;br /&gt;or you can base the definition on a subset. But in either case, and in&lt;br /&gt;both classes and structs, your implementation should follow the five&lt;br /&gt;guarantees of equivalence: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    x.&lt;strong&gt;Equals&lt;/strong&gt;(x) returns &lt;span&gt;&lt;span class=&#39;input&#39;&gt;true. &lt;/span&gt;&lt;/span&gt;This is called the reflexive property.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    x.&lt;strong&gt;Equals&lt;/strong&gt;(y) returns the same value as y.&lt;strong&gt;Equals&lt;/strong&gt;(x). This is called the symmetric property.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    if (x.&lt;strong&gt;Equals&lt;/strong&gt;(y) &amp;amp;&amp;amp; y.&lt;strong&gt;Equals&lt;/strong&gt;(z)) returns &lt;span&gt;&lt;span class=&#39;input&#39;&gt;true&lt;/span&gt;&lt;/span&gt;, then x.&lt;strong&gt;Equals&lt;/strong&gt;(z) returns &lt;span&gt;&lt;span class=&#39;input&#39;&gt;true&lt;/span&gt;&lt;/span&gt;. This is called the transitive property.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Successive invocations of x.&lt;strong&gt;Equals&lt;/strong&gt;(y) return the same value as long as the objects referenced by x and y are not modified.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    x.&lt;strong&gt;Equals&lt;/strong&gt;(null) returns &lt;span&gt;&lt;span class=&#39;input&#39;&gt;false&lt;/span&gt;&lt;/span&gt;. However, null.Equals(null) throws an exception; it does not obey rule number two above.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;br /&gt;                    Any struct that you define already has a default implementation of value equality that it inherits from the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/system.valuetype.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl01&#39;&gt;System&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;ValueType&lt;/a&gt;&lt;/span&gt; override of the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl03&#39;&gt;Object&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;Equals(Object)&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;method. This implementation uses reflection to examine all the public&lt;br /&gt;and non-public fields and properties in the type. Although this&lt;br /&gt;implementation produces correct results, it is relatively slow compared&lt;br /&gt;to a custom implementation that you write specifically for the type. &lt;/p&gt;&lt;p&gt; The implementation details for value equality&lt;br /&gt;are different for classes and structs. However, both classes and&lt;br /&gt;structs require the same basic steps for implementing equality: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Override the &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/9fkccyh4.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl05&#39;&gt;virtual&lt;/a&gt; &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl06&#39;&gt;Object&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;Equals(Object)&lt;/a&gt;&lt;/span&gt; method. In most cases, your implementation of &lt;span class=&#39;code&#39;&gt;bool Equals( object obj )&lt;/span&gt; should just call into the type-specific &lt;span&gt;&lt;span class=&#39;input&#39;&gt;Equals&lt;/span&gt;&lt;/span&gt; method that is the implementation of the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/ms131187.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl08&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl08&#39;&gt;System&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;IEquatable&lt;span class=&#39;cs&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;(Of &lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;(&lt;/span&gt;T&lt;span class=&#39;cs&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;)&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; interface. (See step 2.)&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Implement the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/ms131187.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl12&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl12&#39;&gt;System&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;IEquatable&lt;span class=&#39;cs&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;(Of &lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;(&lt;/span&gt;T&lt;span class=&#39;cs&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;)&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; interface by providing a type-specific &lt;span&gt;&lt;span class=&#39;input&#39;&gt;Equals&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;method. This is where the actual equivalence comparison is performed.&lt;br /&gt;For example, you might decide to define equality by comparing only one&lt;br /&gt;or two fields in your type. Do not throw exceptions from &lt;span&gt;&lt;span class=&#39;input&#39;&gt;Equals&lt;/span&gt;&lt;/span&gt;. For classes only: This method should examine only fields that are declared in the class. It should call &lt;span&gt;&lt;span class=&#39;input&#39;&gt;base.Equals&lt;/span&gt;&lt;/span&gt; to examine fields that are in the base class. (Do not do this if the type inherits directly from &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/system.object.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl16&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl16&#39;&gt;Object&lt;/a&gt;&lt;/span&gt;, because the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/system.object.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl17&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl17&#39;&gt;Object&lt;/a&gt;&lt;/span&gt; implementation of &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl18&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl18&#39;&gt;Object&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;Equals(Object)&lt;/a&gt;&lt;/span&gt; performs a reference equality check.) &lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Optional but recommended: Overload the &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/53k8ybth.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl20&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl20&#39;&gt;==&lt;/a&gt; and &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/3tz250sf.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl21&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl21&#39;&gt;!=&lt;/a&gt; operators.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Override &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl22&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl22&#39;&gt;Object&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;GetHashCode&lt;/a&gt;&lt;/span&gt; so that two objects that have value equality produce the same hash code.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br /&gt;                    Optional: To support definitions for &quot;greater than&quot; or &quot;less than,&quot; implement the &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/4d7sx9hd.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl24&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl24&#39;&gt;IComparable&lt;span class=&#39;cs&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;(Of &lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;(&lt;/span&gt;T&lt;span class=&#39;cs&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;)&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;)&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; interface for your type, and also overload the &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/hx063734.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl27&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl27&#39;&gt;&amp;lt;=&lt;/a&gt; and &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/a59bsyk4.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl28&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl28&#39;&gt;&amp;gt;=&lt;/a&gt; operators.&lt;br /&gt;                &lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;br /&gt;The first example that follows shows a class implementation. The second&lt;br /&gt;example shows a struct implementation. &lt;/p&gt;&lt;/div&gt;&lt;div class=&#39;MTPS_CollapsibleRegion&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198786&#39;&gt;&lt;br /&gt;			&lt;div class=&#39;CollapseRegionLink&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198786_h&#39;&gt;&lt;br /&gt;				&lt;img style=&#39;border-width: 0px; vertical-align: middle;&#39; src=&#39;http://i.msdn.microsoft.com/Global/Images/clear.gif&#39; class=&#39;LibC_o&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198786_i&#39;/&gt; Example&lt;br /&gt;			&lt;/div&gt;&lt;div class=&#39;MTPS_CollapsibleSection&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198786_c&#39; style=&#39;overflow: visible; display: block; height: auto; width: 1393px;&#39;&gt;&lt;div class=&#39;MTPS_CollapsibleSection&#39; id=&#39;&#39; style=&#39;display: block;&#39;&gt;&lt;br /&gt;				&lt;a id=&#39;exampleToggle&#39;/&gt;&lt;p&gt;&lt;br /&gt;                    The following example shows how to implement value equality in a class (reference type). &lt;br /&gt;                &lt;/p&gt;&lt;div id=&#39;snippetGroup&#39;&gt;&lt;div id=&#39;ctl00_rs1_mainContentContainer_ctl41_CSharp&#39; class=&#39;libCScode&#39;&gt;&lt;div class=&#39;CodeSnippetTitleBar&#39;&gt;&lt;div class=&#39;CodeDisplayLanguage&#39;&gt;C#&lt;/div&gt;&lt;div class=&#39;CopyCodeButton&#39;&gt;&lt;a href=&#39;javascript:CopyCode(&amp;apos;ctl00_rs1_mainContentContainer_ctl41CSharp&amp;apos;);&#39; title=&#39;Copy Code&#39; class=&#39;copyCode&#39;&gt;&lt;img height=&#39;9&#39; border=&#39;0&#39; align=&#39;middle&#39; src=&#39;http://i.msdn.microsoft.com/Global/Images/clear.gif&#39; class=&#39;LibC_copy_off&#39;/&gt; Copy Code&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir=&#39;ltr&#39;&gt;&lt;pre space=&#39;preserve&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl41CSharp&#39; style=&#39;white-space: pre-wrap;&#39; class=&#39;libCScode&#39;&gt;&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;namespace&amp;lt;/span&amp;gt; ValueEquality&amp;lt;br /&amp;gt;{&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;using&amp;lt;/span&amp;gt; System;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;class&amp;lt;/span&amp;gt; TwoDPoint : IEquatable&amp;lt;TwoDPoint&amp;gt;&amp;lt;br /&amp;gt;    {&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Readonly auto-implemented properties.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; X { &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;get&amp;lt;/span&amp;gt;; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;private&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;set&amp;lt;/span&amp;gt;; }&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; Y { &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;get&amp;lt;/span&amp;gt;; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;private&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;set&amp;lt;/span&amp;gt;; }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Set the properties in the constructor.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; TwoDPoint(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; x, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; y)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; ((x &amp;lt; 1) || (x &amp;gt; 2000) || (y &amp;lt; 1) || (y &amp;gt; 2000))&amp;lt;br /&amp;gt;                throw &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; System.ArgumentException(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Point must be in range 1 - 2000&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.X = x;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.Y = y;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(object obj)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.Equals(obj as TwoDPoint);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(TwoDPoint p)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// If parameter is null, return false.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(p, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Optimization for a common success case.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;, p))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;true&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// If run-time types are not exactly the same, return false.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.GetType() != p.GetType())&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Return true if the fields match.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Note that the base class is not invoked because it is&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// System.Object, which defines Equals as reference equality.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; (X == p.X) &amp;amp;&amp;amp; (Y == p.Y);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; GetHashCode()&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; X * 0x00010000 + Y;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator ==(TwoDPoint lhs, TwoDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Check for null on left side.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(lhs, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(rhs, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;                {&amp;lt;br /&amp;gt;                    &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// null == null = true.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;true&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;                }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Only the left side is null.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Equals handles case of null on right side.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; lhs.Equals(rhs);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator !=(TwoDPoint lhs, TwoDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; !(lhs == rhs);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// For the sake of simplicity, assume a ThreeDPoint IS a TwoDPoint.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;class&amp;lt;/span&amp;gt; ThreeDPoint : TwoDPoint, IEquatable&amp;lt;ThreeDPoint&amp;gt;&amp;lt;br /&amp;gt;    {&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; Z { &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;get&amp;lt;/span&amp;gt;; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;private&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;set&amp;lt;/span&amp;gt;; }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; ThreeDPoint(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; x, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; y, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; z)&amp;lt;br /&amp;gt;            : &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;base&amp;lt;/span&amp;gt;(x, y)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; ((z &amp;lt; 1) || (z &amp;gt; 2000))&amp;lt;br /&amp;gt;                throw &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; System.ArgumentException(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Point must be in range 1 - 2000&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.Z = z;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(object obj)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.Equals(obj as ThreeDPoint);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(ThreeDPoint p)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// If parameter is null, return false.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(p, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Optimization for a common success case.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt;(Object.ReferenceEquals(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;, p))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;true&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Check properties that this class declares.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Z == p.Z)&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Let base class check its own fields &amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// and do the run-time type comparison.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;base&amp;lt;/span&amp;gt;.Equals((TwoDPoint)p);&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;else&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; GetHashCode()&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; (X * 0x100000) + (Y * 0x1000) + Z;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator ==(ThreeDPoint lhs, ThreeDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Check for null.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(lhs, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (Object.ReferenceEquals(lhs, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;))&amp;lt;br /&amp;gt;                {&amp;lt;br /&amp;gt;                    &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// null == null = true.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;true&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;                }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Only the left side is null.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Equals handles the case of null on right side.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; lhs.Equals(rhs);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator !=(ThreeDPoint lhs, ThreeDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; !(lhs == rhs);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;class&amp;lt;/span&amp;gt; Program&amp;lt;br /&amp;gt;    {&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;void&amp;lt;/span&amp;gt; Main(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;string&amp;lt;/span&amp;gt;[] args)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            ThreeDPoint pointA = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; ThreeDPoint(3, 4, 5);&amp;lt;br /&amp;gt;            ThreeDPoint pointB = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; ThreeDPoint(3, 4, 5);&amp;lt;br /&amp;gt;            ThreeDPoint pointC = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; i = 5;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA.Equals(pointB) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(pointB));&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA == pointB = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == pointB);&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;null comparison = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(pointC));&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Compare to some other type = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(i));&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            TwoDPoint pointD = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            TwoDPoint pointE = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Two null TwoDPoints are equal: {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointD == pointE);&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            pointE = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; TwoDPoint(3, 4);&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;(pointE == pointA) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointE == pointA);&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;(pointA == pointE) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == pointE);&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;(pointA != pointE) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA != pointE);&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            System.Collections.ArrayList list = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; System.Collections.ArrayList();&amp;lt;br /&amp;gt;            list.Add(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; ThreeDPoint(3, 4, 5));&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointE.Equals(list[0]): {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointE.Equals(list[0]));&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Keep the console window open in debug mode.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            System.Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Press any key to exit.&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            System.Console.ReadKey();&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: green;&quot;&amp;gt;/* Output:&amp;lt;br /&amp;gt;        pointA.Equals(pointB) = True&amp;lt;br /&amp;gt;        pointA == pointB = True&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt; comparison = False&amp;lt;br /&amp;gt;        Compare to some other type = False&amp;lt;br /&amp;gt;        Two &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt; TwoDPoints are equal: True&amp;lt;br /&amp;gt;        (pointE == pointA) = False&amp;lt;br /&amp;gt;        (pointA == pointE) = False&amp;lt;br /&amp;gt;        (pointA != pointE) = True&amp;lt;br /&amp;gt;        pointE.Equals(list[0]): False&amp;lt;br /&amp;gt;    */&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;p&amp;gt;&lt;br /&gt;                    On classes (reference types), the default implementation of both &amp;lt;span&amp;gt;&amp;lt;a id=&quot;ctl00_rs1_mainContentContainer_ctl42&quot; onclick=&quot;javascript:Track(&#39;ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl42&#39;,this);&quot; href=&quot;http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx&quot;&amp;gt;Object&amp;lt;span class=&quot;cs&quot;&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class=&quot;vb&quot;&amp;gt;.&amp;lt;/span&amp;gt;&amp;lt;span class=&quot;cpp&quot;&amp;gt;::&amp;lt;/span&amp;gt;&amp;lt;span class=&quot;nu&quot;&amp;gt;.&amp;lt;/span&amp;gt;Equals(Object)&amp;lt;/a&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;methods performs a reference equality comparison, not a value equality&lt;br /&gt;check. When an implementer overrides the virtual method, the purpose is&lt;br /&gt;to give it value equality semantics. &amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&lt;br /&gt;                    The &amp;lt;span&amp;gt;&amp;lt;span class=&quot;input&quot;&amp;gt;==&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; and &amp;lt;span&amp;gt;&amp;lt;span class=&quot;input&quot;&amp;gt;!=&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;operators can be used with classes even if the class does not overload&lt;br /&gt;them. However, the default behavior is to perform a reference equality&lt;br /&gt;check. In a class, if you overload the &amp;lt;span&amp;gt;&amp;lt;span class=&quot;input&quot;&amp;gt;Equals&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; method, you should overload the &amp;lt;span&amp;gt;&amp;lt;span class=&quot;input&quot;&amp;gt;==&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; and &amp;lt;span&amp;gt;&amp;lt;span class=&quot;input&quot;&amp;gt;!=&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; operators, but it is not required.&lt;br /&gt;                &amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&lt;br /&gt;                    The following example shows how to implement value equality in a struct (value type):&lt;br /&gt;                &amp;lt;/p&amp;gt;&amp;lt;div id=&quot;snippetGroup1&quot;&amp;gt;&amp;lt;div class=&quot;libCScode&quot; id=&quot;ctl00_rs1_mainContentContainer_ctl44_CSharp&quot;&amp;gt;&amp;lt;div class=&quot;CodeSnippetTitleBar&quot;&amp;gt;&amp;lt;div class=&quot;CodeDisplayLanguage&quot;&amp;gt;C#&amp;lt;/div&amp;gt;&amp;lt;div class=&quot;CopyCodeButton&quot;&amp;gt;&amp;lt;a class=&quot;copyCode&quot; title=&quot;Copy Code&quot; href=&quot;javascript:CopyCode(&#39;ctl00_rs1_mainContentContainer_ctl44CSharp&#39;);&quot;&amp;gt;&amp;lt;img class=&quot;LibC_copy_off&quot; src=&quot;http://i.msdn.microsoft.com/Global/Images/clear.gif&quot; align=&quot;middle&quot; border=&quot;0&quot; height=&quot;9&quot; /&amp;gt; Copy Code&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div dir=&quot;ltr&quot;&amp;gt;&amp;lt;pre class=&quot;libCScode&quot; style=&quot;white-space: pre-wrap;&quot; id=&quot;ctl00_rs1_mainContentContainer_ctl44CSharp&quot; space=&quot;preserve&quot;&amp;gt;    struct TwoDPoint : IEquatable&amp;lt;TwoDPoint&amp;gt;&amp;lt;br /&amp;gt;    {&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Read/write auto-implemented properties.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; X { &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;get&amp;lt;/span&amp;gt;; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;private&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;set&amp;lt;/span&amp;gt;; }&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; Y { &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;get&amp;lt;/span&amp;gt;; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;private&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;set&amp;lt;/span&amp;gt;; }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; TwoDPoint(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; x, &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; y) : &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;()&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            X = x;&amp;lt;br /&amp;gt;            Y = x;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(object obj)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;if&amp;lt;/span&amp;gt; (obj is TwoDPoint)&amp;lt;br /&amp;gt;            {&amp;lt;br /&amp;gt;                &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;this&amp;lt;/span&amp;gt;.Equals((TwoDPoint)obj);&amp;lt;br /&amp;gt;            }&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;false&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; Equals(TwoDPoint p)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; (X == p.X) &amp;amp;&amp;amp; (Y == p.Y);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; override &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; GetHashCode()&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; X ^ Y;&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator ==(TwoDPoint lhs, TwoDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; lhs.Equals(rhs);&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;public&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;bool&amp;lt;/span&amp;gt; operator !=(TwoDPoint lhs, TwoDPoint rhs)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;return&amp;lt;/span&amp;gt; !(lhs.Equals(rhs));&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;class&amp;lt;/span&amp;gt; Program&amp;lt;br /&amp;gt;    {&amp;lt;br /&amp;gt;        &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;static&amp;lt;/span&amp;gt; &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;void&amp;lt;/span&amp;gt; Main(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;string&amp;lt;/span&amp;gt;[] args)&amp;lt;br /&amp;gt;        {&amp;lt;br /&amp;gt;            TwoDPoint pointA = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; TwoDPoint(3,4);&amp;lt;br /&amp;gt;            TwoDPoint pointB = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; TwoDPoint(3,4);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;int&amp;lt;/span&amp;gt; i = 5;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Compare using virtual Equals, static Equals, and == and != operators.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA.Equals(pointB) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(pointB));&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA == pointB = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == pointB);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Object.Equals(pointA, pointB) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, Object.Equals(pointA, pointB)); &amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// False:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA.Equals(null) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;));&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// False:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;(pointA == null) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;(pointA != null) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA != &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// False:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA.Equals(i) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(i)); &amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// CS0019:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Console.WriteLine(&quot;pointA == i = {0}&quot;, pointA == i); &amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Compare unboxed to boxed.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            System.Collections.ArrayList list = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; System.Collections.ArrayList();&amp;lt;br /&amp;gt;            list.Add(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; TwoDPoint(3,4));&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointE.Equals(list[0]): {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA.Equals(list[0])); &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Compare nullable to nullable and to non-nullable.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            TwoDPoint? pointC = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            TwoDPoint? pointD = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// False:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA == (pointC = null) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == pointC);&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointC == pointD = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointC == pointD); &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            TwoDPoint temp = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;new&amp;lt;/span&amp;gt; TwoDPoint(3,4);&amp;lt;br /&amp;gt;            pointC = temp;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointA == (pointC = 3,4) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointA == pointC); &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            pointD = temp;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// True:&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;pointD == (pointC = 3,4) = {0}&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;, pointD == pointC); &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;            &amp;lt;span style=&quot;color: green;&quot;&amp;gt;// Keep the console window open in debug mode.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;            System.Console.WriteLine(&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&amp;lt;span style=&quot;color: maroon;&quot;&amp;gt;&quot;Press any key to exit.&quot;&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;);&amp;lt;br /&amp;gt;            System.Console.ReadKey();&amp;lt;br /&amp;gt;        }&amp;lt;br /&amp;gt;    }&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;    &amp;lt;span style=&quot;color: green;&quot;&amp;gt;/* Output:&amp;lt;br /&amp;gt;        pointA.Equals(pointB) = True&amp;lt;br /&amp;gt;        pointA == pointB = True&amp;lt;br /&amp;gt;        Object.Equals(pointA, pointB) = True&amp;lt;br /&amp;gt;        pointA.Equals(&amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;) = False&amp;lt;br /&amp;gt;        (pointA == &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;) = False&amp;lt;br /&amp;gt;        (pointA != &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;) = True&amp;lt;br /&amp;gt;        pointA.Equals(i) = False&amp;lt;br /&amp;gt;        pointE.Equals(list[0]): True&amp;lt;br /&amp;gt;        pointA == (pointC = &amp;lt;span style=&quot;color: blue;&quot;&amp;gt;null&amp;lt;/span&amp;gt;) = False&amp;lt;br /&amp;gt;        pointC == pointD = True&amp;lt;br /&amp;gt;        pointA == (pointC = 3,4) = True&amp;lt;br /&amp;gt;        pointD == (pointC = 3,4) = True&amp;lt;br /&amp;gt;    */&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;                    For structs, the default implementation of &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl45&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl45&#39;&gt;Object&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;Equals(Object)&lt;/a&gt;&lt;/span&gt; (which is the overridden version in &lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/system.valuetype.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl47&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl47&#39;&gt;System&lt;span class=&#39;cs&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;vb&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;cpp&#39;&gt;::&lt;/span&gt;&lt;span class=&#39;nu&#39;&gt;.&lt;/span&gt;ValueType&lt;/a&gt;&lt;/span&gt;)&lt;br /&gt;performs a value equality check by using reflection to compare the&lt;br /&gt;values of every field in the type. When an implementer overrides the&lt;br /&gt;virtual &lt;span&gt;&lt;span class=&#39;input&#39;&gt;Equals&lt;/span&gt;&lt;/span&gt; method in a&lt;br /&gt;stuct, the purpose is to provide a more efficient means of performing&lt;br /&gt;the value equality check and optionally to base the comparison on some&lt;br /&gt;subset of the struct&#39;s field or properties. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;                    The &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/53k8ybth.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl49&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl49&#39;&gt;==&lt;/a&gt; and &lt;a href=&#39;http://msdn.microsoft.com/en-us/library/3tz250sf.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198786_c|ctl00_rs1_mainContentContainer_ctl50&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl50&#39;&gt;!=&lt;/a&gt; operators cannot operate on a struct unless the struct explicitly overloads them.&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;			&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;		&lt;/div&gt;&lt;div class=&#39;MTPS_CollapsibleRegion&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198787&#39;&gt;&lt;br /&gt;			&lt;div class=&#39;CollapseRegionLink&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198787_h&#39;&gt;&lt;br /&gt;				&lt;img style=&#39;border-width: 0px; vertical-align: middle;&#39; src=&#39;http://i.msdn.microsoft.com/Global/Images/clear.gif&#39; class=&#39;LibC_o&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198787_i&#39;/&gt; See Also&lt;br /&gt;			&lt;/div&gt;&lt;div class=&#39;MTPS_CollapsibleSection&#39; id=&#39;ctl00_rs1_mainContentContainer_cpe198787_c&#39; style=&#39;overflow: visible; display: block; height: auto; width: 1393px;&#39;&gt;&lt;div class=&#39;MTPS_CollapsibleSection&#39; id=&#39;&#39; style=&#39;display: block;&#39;&gt;&lt;br /&gt;				&lt;a id=&#39;seeAlsoToggle&#39;/&gt;&lt;h4 class=&#39;subHeading&#39;&gt;Concepts&lt;/h4&gt;&lt;div class=&#39;seeAlsoStyle&#39;&gt;&lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198787_c|ctl00_rs1_mainContentContainer_ctl55&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl55&#39;&gt;C# Programming Guide&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 class=&#39;subHeading&#39;&gt;Other Resources&lt;/h4&gt;&lt;div class=&#39;seeAlsoStyle&#39;&gt;&lt;span&gt;&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/dd183752.aspx&#39; onclick=&#39;javascript:Track(&amp;apos;ctl00_rs1_mainContentContainer_cpe198787_c|ctl00_rs1_mainContentContainer_ctl56&amp;apos;,this);&#39; id=&#39;ctl00_rs1_mainContentContainer_ctl56&#39;&gt;Equality Comparisons (C# Programming Guide)&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;			&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;		&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/7831737859945982879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/7831737859945982879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7831737859945982879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7831737859945982879'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/how-to-define-value-equality-for-type-c.html' title='How to: Define Value Equality for a Type (C# Programming)'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-1369010916470059326</id><published>2009-01-21T11:52:00.000-08:00</published><updated>2009-01-21T11:54:10.593-08:00</updated><title type='text'>Restart Firefox - A Great extension to use while developing Firefox Extensions</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;While developing Firefox extensions you need to restart Firefox endlessly. Use this cool extension to do it from the File menu or Toolbar.&lt;br/&gt;&lt;br/&gt;Get &lt;a href=&#39;https://addons.mozilla.org/en-US/firefox/addon/3559&#39; target=&#39;_blank&#39;&gt;Quick Restart&lt;/a&gt;.&lt;br/&gt;&lt;br/&gt;&lt;h4&gt;Long Description&lt;/h4&gt;&lt;br /&gt;    This simple extension adds a &quot;Restart&lt;br /&gt;Firefox&quot; item to the &quot;File&quot; menu. You can also use the Ctrl+Alt+R&lt;br /&gt;keyboard shortcut, or the included toolbar button.&lt;br/&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;To use the toolbar button: right click on toolbar -&amp;gt; Customize... then drag the Restart button to the toolbar.&lt;br/&gt;&lt;br /&gt;&lt;p&gt;Yes, very long...&lt;/p&gt;&lt;h4 id=&#39;reviews&#39;&gt;Reviews&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;    &lt;ul class=&#39;addon-reviews&#39;&gt;&lt;li id=&#39;review-0&#39;&gt;&lt;br /&gt;          &lt;blockquote&gt;&lt;br /&gt;                        &lt;h5&gt; &lt;/h5&gt;&lt;br /&gt;                        &lt;p&gt;A necessary tool for developers testing a bunch of pages that may draw infinite looping errors.&lt;/p&gt;&lt;br /&gt;          &lt;/blockquote&gt;&lt;br /&gt;          &lt;p class=&#39;cite&#39;&gt;&lt;br /&gt;            &lt;br /&gt;&lt;img height=&#39;12&#39; width=&#39;68&#39; title=&#39;Rated 5 out of 5 stars&#39; alt=&#39;&#39; src=&#39;https://addons.mozilla.org/img//ratings/5stars.png&#39;/&gt; &lt;br /&gt;&lt;br /&gt;            &lt;cite&gt;&lt;br /&gt;            by &lt;a class=&#39;profileLink&#39; href=&#39;https://addons.mozilla.org/en-US/firefox/user/3737985&#39;&gt;Angie Schottmuller&lt;/a&gt; on January 16, 2009            &lt;/cite&gt;&lt;br /&gt;          &lt;/p&gt;&lt;br /&gt;        &lt;/li&gt;&lt;li id=&#39;review-1&#39;&gt;&lt;br /&gt;          &lt;blockquote&gt;&lt;br /&gt;                        &lt;h5&gt; &lt;/h5&gt;&lt;br /&gt;                        &lt;p&gt;It&lt;br /&gt;would&#39;ve received 5 stars from me if not for the ugly icon that totally&lt;br /&gt;messes up the file menu. No other options on the file menu has icons,&lt;br /&gt;so it doesn&#39;t look right, especially with such an ugly icon.&lt;/p&gt;&lt;br /&gt;          &lt;/blockquote&gt;&lt;br /&gt;          &lt;p class=&#39;cite&#39;&gt;&lt;br /&gt;            &lt;br /&gt;&lt;img height=&#39;12&#39; width=&#39;68&#39; title=&#39;Rated 1 out of 5 stars&#39; alt=&#39;&#39; src=&#39;https://addons.mozilla.org/img//ratings/1stars.png&#39;/&gt; &lt;br /&gt;&lt;br /&gt;            &lt;cite&gt;&lt;br /&gt;            by &lt;a class=&#39;profileLink&#39; href=&#39;https://addons.mozilla.org/en-US/firefox/user/652966&#39;&gt;Oddish&lt;/a&gt; on January  2, 2009            &lt;/cite&gt;&lt;br /&gt;          &lt;/p&gt;&lt;br /&gt;        &lt;/li&gt;&lt;li id=&#39;review-2&#39;&gt;&lt;br /&gt;          &lt;blockquote&gt;&lt;br /&gt;                        &lt;h5&gt; &lt;/h5&gt;&lt;br /&gt;                        &lt;p&gt;This&lt;br /&gt;is a great extension. FF has many options and settings, when&lt;br /&gt;configuring your setup, it is necessary to constantly restart the&lt;br /&gt;browser to test the changes. This extension performs the session&lt;br /&gt;restore and puts you right back where you were. Awesome!&lt;/p&gt;&lt;br /&gt;          &lt;/blockquote&gt;&lt;br /&gt;          &lt;p class=&#39;cite&#39;&gt;&lt;br /&gt;            &lt;br /&gt;&lt;img height=&#39;12&#39; width=&#39;68&#39; title=&#39;Rated 5 out of 5 stars&#39; alt=&#39;&#39; src=&#39;https://addons.mozilla.org/img//ratings/5stars.png&#39;/&gt; &lt;br /&gt;&lt;br /&gt;            &lt;cite&gt;&lt;br /&gt;            by &lt;a class=&#39;profileLink&#39; href=&#39;https://addons.mozilla.org/en-US/firefox/user/1317061&#39;&gt;wittmeba&lt;/a&gt; on December 18, 2008            &lt;/cite&gt;&lt;br /&gt;          &lt;/p&gt;&lt;br /&gt;        &lt;/li&gt;&lt;/ul&gt;Tell me if it works for you.&lt;br/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/1369010916470059326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/1369010916470059326' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/1369010916470059326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/1369010916470059326'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/restart-firefox-great-extension-to-use.html' title='Restart Firefox - A Great extension to use while developing Firefox Extensions'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-138844775567305728</id><published>2009-01-15T11:21:00.000-08:00</published><updated>2009-01-15T11:38:40.706-08:00</updated><title type='text'>Digg removed links to upcoming pages. Bug or Feature?</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;I believe it was the last version that rolled out on December that first had this bug/feature. The upcoming pages of the specific categories does not have the once-were-links to &quot;Most dugg&quot; and &quot;Most comments&quot; pages of the specific category. Instead, if you click those buttons you get the &quot;most&quot; and &quot;commented&quot; pages of the &quot;All topics&quot; category.&lt;br /&gt;&lt;br /&gt;I would consider that a (poor) feature, unless the URLs of those links look like there is something broken. They are as they were, except that the category name is missing from them.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://1.bp.blogspot.com/_u4nq3fR1ACc/SW-QrFzzb4I/AAAAAAAAADw/W8lYU79SJb4/s1600-h/2009-01-15_2128.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 354px;&quot; src=&quot;http://1.bp.blogspot.com/_u4nq3fR1ACc/SW-QrFzzb4I/AAAAAAAAADw/W8lYU79SJb4/s400/2009-01-15_2128.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5291607157151854466&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The &quot;Programming&quot; category link to upcoming stories with most diggs was once &lt;span style=&quot;font-family:Courier New;&quot;&gt;http://digg.com/all/programming/upcoming/most&lt;/span&gt; and is now &lt;span style=&quot;font-family:Courier New;&quot;&gt;http://digg.com/all//upcoming/most&lt;/span&gt; , like someone dropped the pen in the middle of the sentence. The first link still works, and shows the most dugg stories in programming, but it&#39;s not linked from the site anymore.&lt;br /&gt;&lt;br /&gt;Does anyone knows if this is a bug or a feature? Did you hear or read anything about it? Is this meant to reduce the power of power users? Is another programmer about to lose his job?&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/138844775567305728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/138844775567305728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/138844775567305728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/138844775567305728'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/digg-removed-links-to-upcoming-pages.html' title='Digg removed links to upcoming pages. Bug or Feature?'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_u4nq3fR1ACc/SW-QrFzzb4I/AAAAAAAAADw/W8lYU79SJb4/s72-c/2009-01-15_2128.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-7724931125723174639</id><published>2009-01-15T03:20:00.000-08:00</published><updated>2009-01-15T03:20:00.761-08:00</updated><title type='text'>How to resize the Firefox window with a bookmarklet</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;Many developers work on large screens, but want to Preview web design in a 1024×768 browser screen.&lt;br/&gt;To resize the Firefox browser window to 1024 x 768 create a resizing bookmarklet.&lt;br/&gt;&lt;h4&gt;Creating a Resizing Bookmarklet&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Right click on &lt;strong&gt;Bookmark Toolbar&lt;/strong&gt; -&amp;gt; &lt;strong&gt;New Bookmark&lt;/strong&gt; to launch the Bookmark dialog box.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Insert the following into the box:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Name&lt;/strong&gt;: Give a descriptive name if you are planning to add several bookmarklet.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Location&lt;/strong&gt;: Place &lt;em&gt;&lt;strong&gt;javascript:window.resizeTo(1024,768)&lt;/strong&gt;&lt;/em&gt; into the textfield. Alter &lt;em&gt;&lt;strong&gt;1024&lt;/strong&gt;&lt;/em&gt; &amp;amp; &lt;em&gt;&lt;strong&gt;768&lt;/strong&gt;&lt;/em&gt; to create bookmarklet of another size.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;Both &lt;em&gt;Keywords&lt;/em&gt; and &lt;em&gt;Description&lt;/em&gt; can be left blank.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Test your bookmarklet, click and it should resize to it’s specific size.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/7724931125723174639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/7724931125723174639' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7724931125723174639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7724931125723174639'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/how-to-resize-firefox-window-with.html' title='How to resize the Firefox window with a bookmarklet'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-4725394286873829435</id><published>2009-01-10T12:34:00.000-08:00</published><updated>2009-01-12T13:36:58.399-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Custom fields"/><category scheme="http://www.blogger.com/atom/ns#" term="open source"/><category scheme="http://www.blogger.com/atom/ns#" term="samples"/><category scheme="http://www.blogger.com/atom/ns#" term="Sidebar"/><category scheme="http://www.blogger.com/atom/ns#" term="UGC"/><category scheme="http://www.blogger.com/atom/ns#" term="web2.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Wordpress"/><title type='text'>Using Custom Fields to create a dynamic sidebar</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;p&gt;WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as &lt;b&gt;meta-data&lt;/b&gt;. This &lt;b&gt;meta-data&lt;/b&gt; can include bits of information such as: &lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;b&gt;Mood: Happy&lt;/b&gt; &lt;/li&gt;&lt;li&gt; &lt;b&gt;Currently Reading: Cinderella&lt;/b&gt; &lt;/li&gt;&lt;li&gt; &lt;b&gt;Listening To: Rock Around the Clock&lt;/b&gt; &lt;/li&gt;&lt;li&gt; &lt;b&gt;Weather: Hot and humid&lt;/b&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;With some extra coding, it is possible to achieve more complex actions, such as using the &lt;b&gt;metadata&lt;/b&gt; to store an expiration date for a post. &lt;/p&gt;&lt;p&gt;Meta-data is handled with &lt;b&gt;key/value&lt;/b&gt; pairs.  The &lt;b&gt;key&lt;/b&gt; is the name of the meta-data element.  The &lt;b&gt;value&lt;/b&gt; is the information that will appear in the meta-data list on each individual post that the information is associated with.&lt;br /&gt;&lt;/p&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Getting Custom Fields&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;To fetch meta values use the &lt;tt&gt;&lt;a title=&quot;Function Reference/get post meta&quot; href=&quot;http://codex.wordpress.org/Function_Reference/get_post_meta&quot;&gt;get_post_meta()&lt;/a&gt;&lt;/tt&gt; function: &lt;/p&gt; &lt;pre&gt; get_post_meta($post_id, $key, $single);&amp;lt;br /&amp;gt;&lt;/pre&gt; &lt;ul&gt;&lt;li&gt;&lt;tt&gt;$post_id&lt;/tt&gt; is the ID of the post you want the meta values for. Use &lt;tt&gt;$post-&amp;gt;ID&lt;/tt&gt; to get a post&#39;s ID. &lt;/li&gt;&lt;li&gt;&lt;tt&gt;$key&lt;/tt&gt; is a string containing the name of the meta value you want. &lt;/li&gt;&lt;li&gt;&lt;tt&gt;$single&lt;/tt&gt; can either be &lt;tt&gt;true&lt;/tt&gt; or &lt;tt&gt;false&lt;/tt&gt;. If set to true then the function will return a single result, as a &lt;b&gt;string&lt;/b&gt;. If false, or not set, then the function returns an &lt;b&gt;array&lt;/b&gt; of the custom fields. &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Highly Customized Sidebar using Custom Fields and Categories Per-Post&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;I&#39;ve used WordPress for a few years now, but currently I am in need of help of building custom sidebars on a per-post basis using information stored in custom fields and categories. I&#39;m a web designer by trade, not a programmer, and have some experience with PHP but not enough to do what I need.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;br /&gt;I&#39;m currently designing a website that uses WordPress as a CMS and will be used by location scouts for potential movie and commercial shooting locations. Posts act in two ways: 1. as News (much like a blog) and 2. as an individual location.&lt;/p&gt; &lt;p&gt;Each individual location is categorized using the WordPress category system, however there are over 75 categories including children. Some locations may have up to 3 different categories. On top of that, each location also has a series of custom fields.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Intention&lt;/strong&gt;&lt;br /&gt;When an individual location is being viewed, the purpose of the sidebar is to feature two sets of 3+ locations: 1. via a category based on the posts categories and 2. locations nearby using a custom field stored in the post.&lt;/p&gt; &lt;p&gt;Since some posts may have up to 3 categories in all, I don&#39;t know how to narrow down the category to just one. For instance, the post may have the main category of House with children of Historic &amp;amp; Period 1950s. All I would want is to pull the House category when someone is viewing a home location and list other locations categorized under Houses in the sidebar.&lt;/p&gt; &lt;p&gt;The same is for the Custom Fields application. Here the intention is to pull the zoning area for the location and list other locations in the same zone. &lt;/p&gt; &lt;p&gt;So if I&#39;m looking at a post for a particular location that is categorized under Gas Station and is located in Zone 1, I should see in the sidebar at least 3 other gas stations and 3 different locations in the zone 1.&lt;/p&gt; &lt;p&gt;Since each post is unique concerning a location, the sidebar must spit out specific information. I&#39;ve tried to figure out the code, but can&#39;t make anything work correctly.&lt;/p&gt;&lt;p&gt;Try something like:&lt;/p&gt; &lt;p&gt;&amp;lt;?php $thumb = get_post_meta($post-&amp;gt;ID, &quot;post_thumb&quot;, true); if (!empty($thumb)) { ?&amp;gt;&amp;lt;img class=&quot;alignright size-thumbnail&quot; src=&quot;&amp;lt;? echo $thumb;?&amp;gt;&quot; width=&quot;120&quot; alt=&quot;Thumbnail image for &#39;&amp;lt;?php the_title();?&amp;gt;&#39;&quot; /&amp;gt;&amp;lt;? } ?&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;Another way to handle this issue&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I recently finished the redesign of my blog, &lt;a href=&quot;http://www.thehumanaught.com/blog&quot;&gt;The Humanaught&lt;/a&gt;, and as these things tend to - it came with a few forehead slapping mind scratchers.&lt;/p&gt; &lt;p&gt;The key one being that the design utilized the post’s footer to store comments. On many posts you wouldn’t even know there was a problem, however when I - on occasion - veer from my usual rambling and only write a tiny little blurb, the issue is evident.&lt;/p&gt; Take, for example, a standard page layout. On one side (in my case, the left) you have your content, on the other you have your sidebar, and hanging out at the bottom you’ve your footer (&lt;strong&gt;fig. 1&lt;/strong&gt;). If your content and your sidebar have a roughly equal amount of doodats in them, you’re golden - but when you short change your comment box, your sidebar extends its full length and makes everything look goofy&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Digging into my WordPress template, I needed a dynamic way of determining the size of the content box. For this I threw the following code just above &lt;a href=&quot;http://codex.wordpress.org/The_Loop&quot;&gt;The Loop&lt;/a&gt; of my single.php and page.php pages.&lt;/p&gt; &lt;div style=&quot;white-space: nowrap;&quot; class=&quot;dean_ch&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;re0&quot;&gt;$post&lt;/span&gt; = get_post&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;the_ID&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;, ARRAY_A&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;&lt;br /&gt;    &lt;span class=&quot;re0&quot;&gt;$contlen&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;$post&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;‘post_content’&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;I come out of that with a variable ($contlen) that gives me the character count of my content. Now all I needed to do was pass that variable to my sidebar and use some conditionals (&lt;em&gt;IF bla bla bla&lt;/em&gt;) to decide what should be displayed and what should be cut.&lt;/p&gt; &lt;p&gt;The problem with the standard WordPress template is that the &lt;strong&gt;&amp;lt;?php get_sidebar(); ?&amp;gt;&lt;/strong&gt; that WordPress uses by default to load all the goodies in &lt;strong&gt;sidebar.php&lt;/strong&gt; doesn’t pass variables defined in other areas of the template.&lt;/p&gt; &lt;p&gt;To fix this we change:&lt;/p&gt; &lt;div style=&quot;white-space: nowrap;&quot; class=&quot;dean_ch&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; get_sidebar&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;to&lt;/p&gt; &lt;div style=&quot;white-space: nowrap;&quot; class=&quot;dean_ch&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;TEMPLATEPATH . &lt;span class=&quot;st0&quot;&gt;‘/sidebar.php’&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;Now any variables you set in &lt;strong&gt;single.php&lt;/strong&gt;/&lt;strong&gt;page.php&lt;/strong&gt; will carry over to &lt;strong&gt;sidebar.php&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;Next up, we need to attribute some values to that prioritized list we made a bit earlier. We need to decide after what character count certain sidebar elements will be displayed. As this is all very much a “give or take” solution, figures will vary depending on things like font-size, the size of elements in the sidebar, etc. However, let’s use my numbers for the sake of … well… just because.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;strong&gt;All&lt;/strong&gt; - Search Box, Recent Posts&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&amp;gt;1,000&lt;/strong&gt; - Badges&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&amp;gt;3,500&lt;/strong&gt; - Recent Comments&lt;/li&gt;&lt;li&gt;&lt;strong&gt;&amp;gt;5,000&lt;/strong&gt; - Blogroll&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;To implement this, we just wrap the sidebar elements in IF statements:&lt;/p&gt; &lt;div style=&quot;white-space: nowrap;&quot; class=&quot;dean_ch&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;is_home&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; || &lt;span class=&quot;re0&quot;&gt;$contlen&lt;/span&gt; &amp;gt; &lt;span class=&quot;nu0&quot;&gt;3500&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;    &amp;lt;h2&amp;gt;Recent Comments&amp;lt;/h2&amp;gt;&lt;br /&gt;    &amp;lt;ul&amp;gt;&lt;br /&gt;        &lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; get_recent_comments&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;    &amp;lt;/ul&amp;gt;&lt;br /&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;The &lt;strong&gt;IF statement&lt;/strong&gt; simply says if it is the home/index.php (&lt;strong&gt;is_home()&lt;/strong&gt;) or (&lt;strong&gt;||&lt;/strong&gt;) our content’s length (&lt;strong&gt;$contlen&lt;/strong&gt;) is greater than 3500, display this crap - otherwise, move along.&lt;/p&gt; &lt;p&gt;That about does it, but for the sake of re-illustration, here’s the conditional to display the blogroll:&lt;/p&gt; &lt;div style=&quot;white-space: nowrap;&quot; class=&quot;dean_ch&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;is_home&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; || &lt;span class=&quot;re0&quot;&gt;$contlen&lt;/span&gt; &amp;gt; &lt;span class=&quot;nu0&quot;&gt;5000&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;    &amp;lt;h2&amp;gt;Blogroll&amp;lt;/h2&amp;gt;&lt;br /&gt;    &amp;lt;ul&amp;gt;&lt;br /&gt;        &lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; wp_list_bookmarks&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;    &amp;lt;/ul&amp;gt;&lt;br /&gt;&lt;span class=&quot;kw2&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;What this doesn’t take into account are pages that display things like search results, particularly if those results are few to none. But with some simple modifications, I’m sure you can adjust this method to suit your blog’s particular needs.&lt;/p&gt;Technorati Tags: &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/wordpress%20how%20to&quot; class=&quot;performancingtags&quot;&gt;wordpress how to&lt;/a&gt;, &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/web%202.0&quot; class=&quot;performancingtags&quot;&gt;web 2.0&lt;/a&gt;, &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/wp%20theme&quot; class=&quot;performancingtags&quot;&gt;wp theme&lt;/a&gt;, &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/wp%20themes&quot; class=&quot;performancingtags&quot;&gt;wp themes&lt;/a&gt;, &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/blog%20setup&quot; class=&quot;performancingtags&quot;&gt;blog setup&lt;/a&gt;, &lt;a rel=&quot;tag&quot; href=&quot;http://technorati.com/tag/php%20com&quot; class=&quot;performancingtags&quot;&gt;php com&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/4725394286873829435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/4725394286873829435' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/4725394286873829435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/4725394286873829435'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/using-custom-fields-to-create-dynamic.html' title='Using Custom Fields to create a dynamic sidebar'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-8379413722624198180</id><published>2009-01-08T04:51:00.001-08:00</published><updated>2009-01-08T05:00:03.077-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="download unlocker"/><category scheme="http://www.blogger.com/atom/ns#" term="file to unlock"/><category scheme="http://www.blogger.com/atom/ns#" term="file unlocker"/><category scheme="http://www.blogger.com/atom/ns#" term="foundation server"/><category scheme="http://www.blogger.com/atom/ns#" term="how to unlock a file"/><category scheme="http://www.blogger.com/atom/ns#" term="how to unlock file"/><category scheme="http://www.blogger.com/atom/ns#" term="team foundation"/><category scheme="http://www.blogger.com/atom/ns#" term="team foundation server"/><category scheme="http://www.blogger.com/atom/ns#" term="team foundation server 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="team foundation server 2008"/><title type='text'>How to Unlock a File in Team Foundation Server</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;We&#39;ve all been in the&lt;br /&gt;situation before when a developer goes away for a long weekend (usually&lt;br /&gt;leaving on Thursday) and they forget to check in a file and ensure the&lt;br /&gt;solution builds.  Here is how to deal with that in TFS.  Unlock the&lt;br /&gt;file according to the instructions found here:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://blogs.msdn.com/rimuri/archive/2006/03/06/544686.aspx&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;http://blogs.msdn.com/rimuri/archive/2006/03/06/544686.aspx&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;The gist is that running this command will unlock the file:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;tf undo /workspace:TheirWorkspace;DOMAIN\TheirUserAccount $/path/to/file&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;To get a list of workspaces run this:&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;tf workspaces /owner:DOMAIN\TheirUserAccount /computer:*&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Another way to do this:&lt;/p&gt;&lt;p&gt;One of the rare but critical tasks of Configuration Management is&lt;br /&gt;the unlocking of items locked or checked out by someone else, like an&lt;br /&gt;ex-employee or a developer in the Bahamas while an emergency patch&lt;br /&gt;needs to be pushed out.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Unfortunately, the unlock action is not available in the&lt;br /&gt;context-menu or a GUI but needs to be executed from a command line. I&lt;br /&gt;wonder why it’s not in the GUI, granted deleted files and pending&lt;br /&gt;changes will not necessarily be visible in the GUI but at least the&lt;br /&gt;Undo should be available for visible items while the command line still&lt;br /&gt;provides the all-encompassing functionality.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The help was not very clear, so I’ll simplify the command for you.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;There are 2 possible options for unlocking, viz. unlock or undo (if checked out for Edit).&lt;br /&gt;&lt;br /&gt;The respective command to use is &lt;strong&gt;tf lock /lock:none&lt;/strong&gt; or &lt;strong&gt;tf undo&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The parameters in both cases are the same:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;filename&lt;/span&gt; (in the help topic, this is the itemspec parameter)&lt;br /&gt;&lt;br /&gt;This is the file you want to unlock&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(255, 204, 0);&quot;&gt;/workspace&lt;/span&gt;: [user&#39;s workspace]:[user name]&lt;br /&gt;&lt;br /&gt;The user’s workspace needs to be figured out…by right-clicking the locked item and selecting Properties… and then the Status tab&lt;br /&gt;&lt;br /&gt;The user name is the fully qualified user name, in the form: domain/user&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(153, 204, 0);&quot;&gt;/s&lt;/span&gt;:[server path]&lt;br /&gt;&lt;br /&gt;This is the TFS server in question. Typically it’s &lt;a href=&quot;http://server:8080/&quot;&gt;http://servername:8080/&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So, a sample command would be something like:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;tf undo &lt;span style=&quot;color: rgb(51, 102, 255);&quot;&gt;$/Applications/Dev/Branch1/file1.aspx&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 153, 0);&quot;&gt;/workspace:”Ra Dev Notebook”;corp1\ra&lt;/span&gt; &lt;span style=&quot;color: rgb(153, 204, 0);&quot;&gt;/s:http://altair:8080&lt;/span&gt; &lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;(You run this is on a VS client, at the Visual Studio command prompt)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;PS: Hope the color coding helped&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Another command I found useful during the process was &lt;strong&gt;tf status /user:Joe /s:server path&lt;/strong&gt;, which essentially lists all files locked by Joe. I piped it to a text file (with &amp;gt;&amp;gt; C:\joe.locked.txt) to get a report.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/8379413722624198180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/8379413722624198180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8379413722624198180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8379413722624198180'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/how-to-unlock-file-in-team-foundation.html' title='How to Unlock a File in Team Foundation Server'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-3160938339033591493</id><published>2009-01-08T01:58:00.000-08:00</published><updated>2009-01-08T02:14:21.728-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="access stdev"/><category scheme="http://www.blogger.com/atom/ns#" term="group by"/><category scheme="http://www.blogger.com/atom/ns#" term="normal distribution"/><category scheme="http://www.blogger.com/atom/ns#" term="pooled stdev"/><category scheme="http://www.blogger.com/atom/ns#" term="quartile"/><category scheme="http://www.blogger.com/atom/ns#" term="standard deviation"/><category scheme="http://www.blogger.com/atom/ns#" term="standard deviations"/><category scheme="http://www.blogger.com/atom/ns#" term="stdev"/><category scheme="http://www.blogger.com/atom/ns#" term="stdev formula"/><category scheme="http://www.blogger.com/atom/ns#" term="stdev sql"/><category scheme="http://www.blogger.com/atom/ns#" term="stdev stdevp"/><category scheme="http://www.blogger.com/atom/ns#" term="stdevp"/><category scheme="http://www.blogger.com/atom/ns#" term="sumproduct"/><category scheme="http://www.blogger.com/atom/ns#" term="variance"/><category scheme="http://www.blogger.com/atom/ns#" term="vba stdev"/><category scheme="http://www.blogger.com/atom/ns#" term="z score"/><title type='text'>A User-Friendly C# Descriptive Statistic Class</title><content type='html'>Today I found and used this class, I highly recommend it for simple statistics calculations required for many reporting systems.&lt;br /&gt;&lt;a href=&quot;http://www.codeproject.com/KB/recipes/DescriptiveStatisticClass.aspx&quot;&gt;&lt;br /&gt;http://www.codeproject.com/KB/recipes/DescriptiveStatisticClass.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The author says:&lt;br /&gt;&lt;br /&gt;&quot;The 80-20 rules applies: even with the advances of statistics, most of our work requires only univariate descriptive statistics – those involve the calculations of mean, standard deviation, range, skewness, kurtosis, percentile, quartiles, etc. This article describes a simple way to construct a set of classes to implement descriptive statistics in C#. The emphasis is on the ease of use at the users&#39; end.&quot;&lt;br /&gt;&lt;br /&gt;It has great reviews and ratings.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/3160938339033591493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/3160938339033591493' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/3160938339033591493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/3160938339033591493'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2009/01/user-friendly-c-descriptive-statistic.html' title='A User-Friendly C# Descriptive Statistic Class'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-4336304888754625442</id><published>2007-06-19T12:55:00.000-07:00</published><updated>2007-06-19T13:22:17.131-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bbc"/><category scheme="http://www.blogger.com/atom/ns#" term="cnn"/><category scheme="http://www.blogger.com/atom/ns#" term="delicious"/><category scheme="http://www.blogger.com/atom/ns#" term="digg"/><category scheme="http://www.blogger.com/atom/ns#" term="news"/><category scheme="http://www.blogger.com/atom/ns#" term="news industry"/><category scheme="http://www.blogger.com/atom/ns#" term="stumbleupon"/><category scheme="http://www.blogger.com/atom/ns#" term="web2.0"/><title type='text'>Digg wins news industry sites comparison</title><content type='html'>During the last 3 years there has been an enourmous shift in the news industry from classic news sites such as &lt;a href=&quot;http://www.cnn.com/&quot;&gt;CNN.com&lt;/a&gt; and &lt;a href=&quot;http://www.BBC.co.uk/&quot;&gt;BBC.co.uk&lt;/a&gt; to web2.0 news site made of User generated content, such as &lt;a href=&quot;http://www.digg.com&quot;&gt;Digg&lt;/a&gt;, &lt;a href=&quot;http://del.icio.us&quot;&gt;Delicious&lt;/a&gt; and &lt;a href=&quot;http://www.StumbleUpon.com/&quot;&gt;StumbleUpon&lt;/a&gt;. I checked these 5 sites on &lt;a href=&quot;http://www.alexa.com&quot;&gt;alexa&lt;/a&gt; to see how they do head to head.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://bp0.blogger.com/_u4nq3fR1ACc/Rng3yNFmtuI/AAAAAAAAABU/D0vcLLUUfzM/s1600-h/DiggCompared_1y.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 414px; height: 309px;&quot; src=&quot;http://bp0.blogger.com/_u4nq3fR1ACc/Rng3yNFmtuI/AAAAAAAAABU/D0vcLLUUfzM/s400/DiggCompared_1y.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5077869915506390754&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;first I looked at the 1 year graph. Everyone seem very stable, with CNN and BBC leading, Digg takes the middle, followed by Delicious and StumbleUpon. The weekend effect is apparent at 3 of the sites.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rng49tFmtvI/AAAAAAAAABc/81DsytVeOAA/s1600-h/DiggCompared_3y.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rng49tFmtvI/AAAAAAAAABc/81DsytVeOAA/s400/DiggCompared_3y.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5077871212586514162&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;when I looked at the 3 Year graph, i could easily see that CNN and BBC where at approximatly the same ranking, where as the web2.0 sites were nowhere in site 3 years ago. After 2 years of rising sharply Digg and Delicious (strangly matching all the way) leveled around 100, 150. Another thing is that CNN and BBC started declining 2 years ago, and they keep going slowly but steadily. It so happened that Digg and CNN has very similar rank, as one takes the others place.&lt;br /&gt;&lt;br /&gt;I expect great things for digg, and I think they will lead the revolution of web2.0 many years to come.&lt;br /&gt;&lt;br /&gt;CNN is dead, Long live Digg ;-)&lt;br /&gt;&lt;br /&gt;Benny.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/4336304888754625442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/4336304888754625442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/4336304888754625442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/4336304888754625442'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/06/digg-wins-news-industry-sites.html' title='Digg wins news industry sites comparison'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://bp0.blogger.com/_u4nq3fR1ACc/Rng3yNFmtuI/AAAAAAAAABU/D0vcLLUUfzM/s72-c/DiggCompared_1y.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-3498234407501361816</id><published>2007-06-18T13:55:00.000-07:00</published><updated>2007-06-18T14:33:49.013-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="business objects"/><category scheme="http://www.blogger.com/atom/ns#" term="data transfer"/><category scheme="http://www.blogger.com/atom/ns#" term="dataset"/><category scheme="http://www.blogger.com/atom/ns#" term="design"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><category scheme="http://www.blogger.com/atom/ns#" term="web2.0"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><title type='text'>Designing Business Objects for web2.0 Applications</title><content type='html'>When we sit down at the beginning of the process to design our brand new shiny web2.0 application (Please, not another social network...) we should consider several issues regarding Object Oriented design in general, as well as  web2.0 application specifically.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Find your objects&lt;/span&gt;&lt;br /&gt;This is true for every program. First thing to do is read the product specification (if working in medium or large company) or just describe the system in words. Notice the objects in your sentences as candidates for being objects in the system. For each one ask yourself: &quot;Does it contain any information i should use?&quot; This Information is the object properties. &quot;What actions can this object perform?&quot; leads to a list of methods. Objects on the list that have no properties or methods should not be objects in the system.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Remember the Channels&lt;br /&gt;&lt;/span&gt;When selecting parameters for the methods and types for the properties remember who is on the other side. Is that a web page calling? A web service? Some Embedded code from this blog?&lt;br /&gt;What are they asking for? What language do they speak?&lt;br /&gt;You may consider writing a Data Access Layer that speaks SQL with the database and sends DataSet objects to the Business Objects. The business objects receive requests from Server-Side code that runs inside a web server. Those requests use a certain textual format to pass data to the server. Simple applications may send single values over Query Strings, but any real application should use JSON or XML as a data protocol with the web client. On this web client you may like to have some cool AJAX controls to smooth the User Experience, So you will need a set of Client-Side objects, written usually in Javascript.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Design Serializable Objects&lt;/span&gt;&lt;br /&gt;If you are using JSON or XML you should design your objects to be serializeable. That means using only string, int, bool, object and array as the types of your properties. Any JSON Serializer can read such objects and this saves you iterating through all the object properties to read it&#39;s values. You just write something like MyJSONString = Serializer.Serialize(MyObject) and Bam! you got yourself a JSON string to send back to the browser.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Match Server and Client Objects&lt;/span&gt;&lt;br /&gt;Since we have two sets of objects, one on the server and one on the client, we should match their properties to allow for smooth data transfer. There are JSON and XML serializers in javascript too, of course. You can avoid this problem all together by using a Library planned for this purpose like the &lt;a href=&quot;http://ajax.asp.net/&quot;&gt;Microsoft Ajax Extensions 1.0&lt;/a&gt;. Take a look but be careful, this package is only for professionals. It requires the best understanding of Internet technologies and much patience for Microsoft heavy object models.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Plan Great Utilities&lt;/span&gt;&lt;br /&gt;Well, What do we do with all this? We can start by writing a set of utilities that will simplify our coding and will make the application more robust. One function we should write is a generic DataSet2Object function, that reads a dataset and returns a collection of the desired objects. There may be some others, but you get the idea.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Remember to breath :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Benny.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/3498234407501361816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/3498234407501361816' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/3498234407501361816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/3498234407501361816'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/06/designing-business-objects-for-web20.html' title='Designing Business Objects for web2.0 Applications'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-9004441171328457774</id><published>2007-06-13T12:10:00.000-07:00</published><updated>2007-06-13T12:38:52.480-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="actionscript"/><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="flash"/><category scheme="http://www.blogger.com/atom/ns#" term="page"/><category scheme="http://www.blogger.com/atom/ns#" term="player"/><category scheme="http://www.blogger.com/atom/ns#" term="url"/><category scheme="http://www.blogger.com/atom/ns#" term="video"/><title type='text'>Reporting Page Url from Flash video player = Monitization</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:180%;&quot; &gt;R&lt;/span&gt;ecently the web got at least one more layer in the spaghetti of sites we are used to. Since the rising of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Social_network&quot;&gt;social networks&lt;/a&gt; and the &lt;a href=&quot;http://www.jupiterresearch.com/bin/item.pl/research:vision/63/id=99251/&quot;&gt;User Generated Content sites&lt;/a&gt; everyone is providing the users with tools to embed parts of their web site in the user&#39;s blog, profile or other personalized web space. Now instead of many sites operating in solitude we now have one web page that includes information from many web sources.&lt;br /&gt;&lt;br /&gt;A more recent development was the rich media, Images and &lt;a href=&quot;http://www.5min.com/&quot;&gt;video&lt;/a&gt; mainly. Most video sites now allow their users to embed their videos everywhere (except of &lt;a href=&quot;http://www.myspace.com/&quot;&gt;MySpace&lt;/a&gt;... but that is another story that will probably have it&#39;s own post.). How can the video site owner know when someone is playing his video on some blog or profile? Remember that most of the video sites business model are commercial-based, and the commercials should run along-side with the video content, So targeting your embedded audience even just for GeoLocation can be worth a lot.&lt;br /&gt;&lt;br /&gt;Most video players are written in flash, and the communication between Flash and web server never was that amazing. There are several things you need to do in order to have a Flash application report to a web server the Url of the page it is running inside.&lt;br /&gt;&lt;br /&gt;First you need to use an ActionScript command called ExecuteExternalCall to call a javascript that reports the Page Url with the property document.location.href.&lt;br /&gt;Set the AllowScripts attribute of the embed tag to &quot;Always&quot;, and make sure that the hosting site allows those scripts to run. MySpace doesn&#39;t, so do try to execute any Javascript in any form on MySpace.&lt;br /&gt;&lt;br /&gt;this will take you to a point where everything works fine in FireFox but no information received from explorer browsers. To allow this info to run through IE you need to add the Flash ClassId attribute to the embed tag, and remove the Type attribute (should be there before, with Flash/Application or something like that in it&#39;s value). At this point we got the Url from IE as well but our application stoped working.&lt;br /&gt;&lt;br /&gt;We are still resolving this issue, and we might try sending Ajax request to the server straight from the &quot;ExecuteExternalApplication&quot; function, because we realized that the function call works fine, only getting the value back in ActionScript fails.&lt;br /&gt;&lt;br /&gt;I&#39;ll update on this when we have more info, also I will appreciate any comments on how to handle such a trick.&lt;br /&gt;&lt;br /&gt;benny.PublishPost();</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/9004441171328457774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/9004441171328457774' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/9004441171328457774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/9004441171328457774'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/06/reporting-page-url-from-flash-video.html' title='Reporting Page Url from Flash video player = Monitization'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-7654638566063184698</id><published>2007-06-05T10:16:00.000-07:00</published><updated>2007-06-05T11:21:54.487-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="anger"/><category scheme="http://www.blogger.com/atom/ns#" term="development process"/><category scheme="http://www.blogger.com/atom/ns#" term="emotions"/><category scheme="http://www.blogger.com/atom/ns#" term="intuition"/><category scheme="http://www.blogger.com/atom/ns#" term="relax"/><title type='text'>The place of Intuition in the Development process</title><content type='html'>I&#39;m developing software for the last 10 years, and operating computers for 20. I have watched endless programmers, team leaders, project managers and &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;CTOs&lt;/span&gt; bang their heads (or do other stupid things) with anger and &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;frustration&lt;/span&gt; every time they observed the non-disputable fact of life that computers don&#39;t always do what we want them to. Hell, they sometimes don&#39;t even do what they were asked to do (Which is something &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;completely&lt;/span&gt; different from what we expect them to do.)&lt;br /&gt;&lt;br /&gt;This is a universal truth and software developers can benefit the most from integrating it into our systems: Things don&#39;t always work as we expect. The difference between us is what we do with this fact.&lt;br /&gt;&lt;br /&gt;As i see it there are mainly two ways to handle this. Some ignore reality and stick to their opinions. We can see these guys shouting and hitting their computers and some of them develop &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;habits&lt;/span&gt; of &quot;saying YES and doing NO&quot;, always being late and other &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;behaviors&lt;/span&gt; that express &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;repressed&lt;/span&gt; anger. On a more professional level you may notice some programmers that insist on sticking to their bugs and can spend days with them, even if they could solve them quickly. By &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;struggling&lt;/span&gt; with their work they &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;achieve&lt;/span&gt; much self &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;feedback&lt;/span&gt; like &quot;I&#39;m working so hard&quot; and &quot;This job is so difficult, I must be so smart to be doing it&quot;.&lt;br /&gt;&lt;br /&gt;Others accept reality and recognize the emotions that this reality stir in them. Those people will usually act according to decisions and not emotions. They also can be stressed or relaxed in their work, but they will at least do a &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;genuine&lt;/span&gt; effort to make things better both professionally and inter-personally. The amount of stress that we &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;acquire&lt;/span&gt; in work is directly connected to the way we recognize and process our feeling and emotions during the day of work. If we know how to harness these powerful emotions to our use we can &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;achieve&lt;/span&gt; so much more then if we are fighting the emotions, working hard to keep them inside.&lt;br /&gt;&lt;br /&gt;The development of software is a very complex task, constructed of many many little tasks that we perform and put together in order to create a complete product or feature. All this complexity it done using a very, very, very and some more complex hardware that includes billions of tiny electrical components. I wonder it actually works at all ! No wonder it has it&#39;s &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;glitches&lt;/span&gt;. To me it reminds a sentence from chaos theory that states that systems become more chaotic as they become more complex. I believe that computers are so complex that they conform to this rule.&lt;br /&gt;&lt;br /&gt;Those that accept reality looks at every bug as an &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;opportunity&lt;/span&gt; to improve, to learn new things, a &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;challenge&lt;/span&gt; that needs to be met, not a problem that needs to be solved. Such state of mind creates a relaxed, interesting, fruitful working &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;environment&lt;/span&gt;. This is the right ground to promote creative thinking and creative solutions. With such inner position we can learn new things easily and enjoy the learning. After all, if there are no more bugs our work is done. The essence of our work is bug fixing. This is what we do. Everyone can create bugs. not all of them can solve them.&lt;br /&gt;&lt;br /&gt;After a while working in this state of mind one starts to write less, but more efficient code. One is found more time thinking then hitting on keys, but get more work done faster. When it comes to approaching new challenges, one starts to use it&#39;s intuition. Sometimes we &quot;just know&quot; things. It is stupid to ask a beginner to use Intuition. He should work by the rules for a while. But after a while, the solutions start &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;popping&lt;/span&gt; up like popcorn. There are many ways to do each task and choosing the right one is many times an intuitive decision. We usually don&#39;t have time to explore all the options well, and we have to choose. These decisions should be taken by an experienced person, and he will be stupid NOT to use intuition in his decisions.&lt;br /&gt;&lt;br /&gt;Our intuition is our highest inner voice (emotions-thoughts-intuition) and only by using it can we &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;achieve&lt;/span&gt; self-completion in our life and in our work.&lt;br /&gt;&lt;br /&gt;I know, there is no code sample with this post. I think developers can still benefit from it...&lt;br /&gt;&lt;br /&gt;yours,&lt;br /&gt;&lt;br /&gt;Benny.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/7654638566063184698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/7654638566063184698' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7654638566063184698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7654638566063184698'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/06/place-of-intuition-in-development.html' title='The place of Intuition in the Development process'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-5534717831945363744</id><published>2007-05-31T12:33:00.000-07:00</published><updated>2007-06-05T11:19:53.124-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="code samples"/><category scheme="http://www.blogger.com/atom/ns#" term="codeplex"/><category scheme="http://www.blogger.com/atom/ns#" term="control toolkit"/><category scheme="http://www.blogger.com/atom/ns#" term="controls"/><category scheme="http://www.blogger.com/atom/ns#" term="demo"/><category scheme="http://www.blogger.com/atom/ns#" term="microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="open source"/><category scheme="http://www.blogger.com/atom/ns#" term="samples"/><title type='text'>ASP.NET AJAX Control Toolkit</title><content type='html'>Check out the new &lt;a href=&quot;http://ajax.asp.net/toolkit/default.aspx&quot;&gt;Ajax controls&lt;/a&gt; from &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;Microsoft&lt;/span&gt;, featured on &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;CodePlex&lt;/span&gt;, their open source site. They have some neat solutions to tasks that we had some hard time doing before this toolkit came to be, and they are giving it away for free right now. On the site check out the live demo they have, it show samples to all the controls.&lt;br /&gt;&lt;br /&gt;I have not &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;started&lt;/span&gt; to use it yet, but my company &lt;a href=&quot;http://www.5min.com/&quot;&gt;5min.com&lt;/a&gt; intends to use it from now on, so I will be reporting about progress and problems with this kit, and &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;probably&lt;/span&gt; some code samples of my own.&lt;br /&gt;&lt;br /&gt;If any of you out there has any experience with this toolkit or with asp.net Ajax library I would like to hear how it is going for you.&lt;br /&gt;&lt;br /&gt;Benny.Publish();</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/5534717831945363744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/5534717831945363744' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5534717831945363744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5534717831945363744'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/05/aspnet-ajax-control-toolkit.html' title='ASP.NET AJAX Control Toolkit'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-2113208285745129786</id><published>2007-05-18T04:00:00.000-07:00</published><updated>2007-05-18T08:59:25.768-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="actionscript"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="flash"/><category scheme="http://www.blogger.com/atom/ns#" term="http"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><category scheme="http://www.blogger.com/atom/ns#" term="loadvars"/><title type='text'>Using JSON to connect Flash with Asp.Net</title><content type='html'>Life of a programmer are becoming more and more simple when it comes to finding professional help online. Almost any question i have regarding my work, like how to do this, why that doesn&#39;t work, etc&#39; I can always find the answer one google search away. Few clicks later i have an explenation, code sample or other solutions. This week i tried to do something that had no good samples or documentation. That made me feel like i have reached the limits of existing technology, and know i&#39;m trying things that other never did before. It is quite exciting for me.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This week Alexey and I wrote a simple &quot;Invite a friend&quot; feature. There is nothing exciting about that in itself. The feature was written inside a Flash control and the business object that actually sends emails is part of our site&#39;s engine written in Asp.Net.&lt;br /&gt;Http communication between Flash and web pages is common, and can be done by using the LoadVars object in ActionScript code. You can see a good example &lt;a href=&quot;http://www.sephiroth.it/tutorials/flashPHP/loadVars/&quot;&gt;here&lt;/a&gt;. There are practicaly 3 ways to transfer data over Http to Flash objects. One is sending the data &quot;as is&quot;, which is good when you pass one parameter or two. Two is using XML to pack the data on one side and unpack it on the other side. Three is using JSON as the data structure standard. I chose JSON because the code required to Serialize and Deserialize JSON objects and strings is much simpler, shorter, more intuitive and more object oriented. You will see in the samples that one line of code is required in every side of the interaction to persist objects over http between Asp.Net and Flash ActionScript, or any other two sides for that matter.&lt;br /&gt;&lt;br /&gt;The c# code for creating Json object on the server is available &lt;a href=&quot;http://newtonsoft.com/products/json/&quot;&gt;here&lt;/a&gt; and uses Newtonsoft Json.Net objects.&lt;br /&gt;The Actionscript code however, is not available on the internet yet, only here. this code recieves the Json object inside Flash and reads it&#39;s values like this: ( I got this code from &lt;a href=&quot;http://designvox.com/&quot;&gt;Trannie&lt;/a&gt; who wrote the &lt;a href=&quot;http://json.org/JSON.as&quot;&gt;Json ActionScript 2 object&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;q&quot; id=&quot;q_1128c13c9f1a466b_0&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;q&quot; id=&quot;q_1128c13c9f1a466b_0&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;In my projects I used LoadVars to grab the JSON string, so my JSON file&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;had a NAME=VALUE format with VALUE being the JSON string:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;client= {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;name&quot;    : &quot;Client&quot;, &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;crop&quot;    : { &quot;x1&quot; : 3, &quot;y1&quot; : 3, &quot;x2&quot; : 623, &quot;y2&quot; : 472 },&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;link&quot;    : {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                &quot;type&quot; : &quot;site&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                &quot;url&quot;  : &quot; &lt;/span&gt;&lt;a style=&quot;font-family: courier new;&quot; href=&quot;http://www.clientsite.com/&quot; target=&quot;_blank&quot; onclick=&quot;return top.js.OpenExtLink(window,event,this)&quot;&gt;http://www.clientsite.com&lt;/a&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        },&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;title&quot;   : &quot;Job Name&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;text&quot;    : &quot;This is a string describing the project&quot;, &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        &quot;details&quot; : [&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        &quot;full&quot;&lt;/span&gt;&lt;wbr style=&quot;font-family: courier new;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;  : &quot;Browse.jpg&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        &quot;thumb&quot; : &quot;THB_Browse.jpg&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                }, &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        &quot;full&quot;&lt;/span&gt;&lt;wbr style=&quot;font-family: courier new;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;  : &quot;HSWebShot2.jpg&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                        &quot;thumb&quot; : &quot;THB_HSWebShot2.jpg&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                ]&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;} &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;Hopefully that is still valid JSON.  It&#39;s an excerpt from a JSON file,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;so I may have introduced some typos..&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;In AS, I&#39;d do something like:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;var client:Object;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;var json = new JSON();&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;var lv:LoadVars = new LoadVars();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;lv.onLoad = function(success) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        if(success) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                client = json.parse(this.client);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                trace(&lt;/span&gt;&lt;a style=&quot;font-family: courier new;&quot; href=&quot;http://client.name/&quot; target=&quot;_blank&quot; onclick=&quot;return top.js.OpenExtLink(window,event,this)&quot;&gt;client.name&lt;/a&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt; );&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                trace(client.details[1]);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;                getURL(client.link.url);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We had some trouble on the ActionScript side because we confused the LoadVars Http object with the internal Json object, so let me elaborate on this. the LoadVars object is the one that use Load method to send Http request to the server, and the onLoad callback function that recieves the response from the server. In order to send Json string in such a request you should use ActionScript syntax to wrap your Json string. The response stream should include the &quot;client =&quot; part, which is NOT generated by the Json server-side class. This part is actually not part of Json, but is used by the Flash LoadVars object in order to read this Json string in ActionScript.&lt;br /&gt;&lt;br /&gt;Finally, i want to hear from you what kind of uses can you see for such technology that connects Flash applications with Asp.Net objects so smoothly and easily.&lt;br /&gt;&lt;br /&gt;Until next time,&lt;br /&gt;&lt;br /&gt;Benny.Serialize(this)</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/2113208285745129786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/2113208285745129786' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/2113208285745129786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/2113208285745129786'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/05/using-json-to-connect-flash-with-aspnet.html' title='Using JSON to connect Flash with Asp.Net'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-7211024469016307865</id><published>2007-05-09T10:17:00.000-07:00</published><updated>2007-05-09T11:49:20.327-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="json"/><title type='text'>Using JSON in AJAX based applications</title><content type='html'>&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;Who the hell is Json ?&lt;/span&gt;&lt;br /&gt;Ajax is a very popular way to create dynamic web2.0 style web pages. It is a method of making asynchronous Javascript calls from web pages to web servers, allowing  web pages that refresh different parts of the page with server data without loading the whole page every time. Ajax is used for many different tasks from news reels to rating widgets and much more. The Ajax interface is simple and open. Send an Http request with parameters info, and receive a call-back with the Http response. You can send anything both ways, but when you need to move large chunks of complex data you are on your own. You have to define the data structures, take care of any errors that happen, and so on.&lt;br /&gt;&lt;br /&gt;Json stands for &lt;span style=&quot;font-weight: bold;&quot;&gt;J&lt;/span&gt;ava&lt;span style=&quot;font-weight: bold;&quot;&gt;S&lt;/span&gt;cript &lt;span style=&quot;font-weight: bold;&quot;&gt;O&lt;/span&gt;bject &lt;span style=&quot;font-weight: bold;&quot;&gt;N&lt;/span&gt;otation. Json is a protocol (like Xml is) for defining data passed through Ajax requests and responses. Json does not have to be used only with Ajax, it can be used to define javascript objects out of any data received to the browser. But Json is at it&#39;s best with Ajax, which demands some standard protocol for moving data through it.&lt;br /&gt;&lt;br /&gt;Json is supported on many platforms, like other open standards, and I will share my experience using it with Asp.Net and Visual Studio.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;Who likes Json ?&lt;/span&gt;&lt;br /&gt;Json is good for any Ajax situation that uses more then one or two parameters. The sites that make the most out of it are those built Object Oriented. Json is a simple way to maintain in Javascript Client code the same Object structure that you use on the server for  getting the data and using your business-objects. If you keep to the same objects  structure even through your Xhtml code and Css files, you will get a very flexible and stable site.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;font-size:130%;&quot; &gt;Implementing Json&lt;/span&gt;&lt;br /&gt;Because Json is a client-server protocol there are two sides to the implementation :)&lt;br /&gt;For server side i use Newtonsoft Json.NET. It is a Dll file and Xml file that reside in your bin directory of the site, and allows you (after creating the proper reference) to write this kind of code in your server pages:&lt;br /&gt;&lt;br /&gt;&lt;center&gt;   &lt;div class=&quot;overflowpanel&quot; style=&quot;width: 80%; text-align: left;&quot;&gt;    &lt;div    style=&quot;background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:9pt;color:black;&quot; class=&quot;code&quot;&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:teal;&quot;&gt;Product&lt;/span&gt; product = &lt;span style=&quot;color:blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:teal;&quot;&gt;Product&lt;/span&gt;();&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt; &lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;product.Name = &lt;span style=&quot;color:maroon;&quot;&gt;&quot;Apple&quot;&lt;/span&gt;;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;product.Expiry = &lt;span style=&quot;color:blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:teal;&quot;&gt;DateTime&lt;/span&gt;(2008, 12, 28);&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;product.Price = 3.99M;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;product.Sizes = &lt;span style=&quot;color:blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt;[] { &lt;span style=&quot;color:maroon;&quot;&gt;&quot;Small&quot;&lt;/span&gt;, &lt;span style=&quot;color:maroon;&quot;&gt;&quot;Medium&quot;&lt;/span&gt;, &lt;span style=&quot;color:maroon;&quot;&gt;&quot;Large&quot;&lt;/span&gt; };&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt; &lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt; output = &lt;span style=&quot;color:teal;&quot;&gt;JavaScriptConvert&lt;/span&gt;.SerializeObject(product);&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//{&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//  &quot;Name&quot;: &quot;Apple&quot;,&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//  &quot;Expiry&quot;: new Date(1230422400000),&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//  &quot;Price&quot;: 3.99,&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//  &quot;Sizes&quot;: [&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//    &quot;Small&quot;,&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//    &quot;Medium&quot;,&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//    &quot;Large&quot;&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//  ]&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:green;&quot;&gt;//}&lt;/span&gt;&lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt; &lt;/pre&gt;    &lt;pre style=&quot;margin: 0px;&quot;&gt;&lt;span style=&quot;color:teal;&quot;&gt;Product&lt;/span&gt; deserializedProduct =&lt;br /&gt; (&lt;span style=&quot;color:teal;&quot;&gt;Product&lt;/span&gt;)&lt;span style=&quot;color:teal;&quot;&gt;JavaScriptConvert&lt;/span&gt;.DeserializeObject(output, &lt;span style=&quot;color:blue;&quot;&gt;typeof&lt;/span&gt;(&lt;span style=&quot;color:teal;&quot;&gt;Product&lt;/span&gt;));&lt;/pre&gt;    &lt;/div&gt;   &lt;/div&gt;  &lt;/center&gt;&lt;br /&gt;This code is a sample of how to convert any custom object that you use in your site to a string in Json format. This string is passed back to the client inside the Ajax response. The last line of code shows how to reverse the process, and convert Json strings that are received from the client into server objects.&lt;br /&gt;&lt;br /&gt;On the client side things look much the same, to the surprise of many Javascript programmers, me included.&lt;br /&gt;In order to parse the Json strings into Javascript objects on the client I use the json.js file from Json.org. It includes a Json parser. The client side code for reading a Json string will be:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;var myObject = myJSONtext.parseJSON(filter);&lt;/pre&gt;Then you can use myObject to access all his properties as they were on the server. Json supports any structure that includes objects with pairs of name-value properties inside them, and arrays of these objects, in any depth of nesting.&lt;br /&gt;When you are done juggling these objects on the client you can send them back to the server, maybe with updated data or even send totally different objects. anyway, the code will look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;var myJSONText = myObject.toJSONString();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is pretty much the basics of json, but there is much more, so expect more on Json soon.&lt;br /&gt;&lt;br /&gt;If you are using Json in your work please reply and tell me how is it working for you, and what you are using it for.&lt;br /&gt;&lt;br /&gt;Benny is inlove with Json :)</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/7211024469016307865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/7211024469016307865' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7211024469016307865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7211024469016307865'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/05/using-json-in-ajax-based-applications.html' title='Using JSON in AJAX based applications'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-7181796679435054525</id><published>2007-05-04T15:52:00.000-07:00</published><updated>2007-05-04T16:24:41.246-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="google"/><category scheme="http://www.blogger.com/atom/ns#" term="http handler"/><category scheme="http://www.blogger.com/atom/ns#" term="permalink"/><category scheme="http://www.blogger.com/atom/ns#" term="sitemap"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><category scheme="http://www.blogger.com/atom/ns#" term="xmldocument"/><title type='text'>Creating and Submitting a Sitemap to Google</title><content type='html'>As many know, Google search results are based on a crawler software that surfs our sites like a regular user, more or less. If for some reason we have pages on our site that are not linked from any other page, they will not appear in search results. In order to improve google&#39;s crawling in our site we should send google a link to an Xml file that we create in our site, and in this file we can list all the site&#39;s pages that we want Google to show in his search results. This file is called a Sitemap.&lt;br /&gt;&lt;br /&gt;If a site is made of static pages, you just write them down in your file and you are done. All you need to do now (After submitting the Sitemap, of course) is to update the file with any new pages that you create. If, on the other hand, you are running a dynamic site that pulls it&#39;s pages out of a database, you have more work to do.&lt;br /&gt;&lt;br /&gt;First, you need to create a Permalink for every page. Permalink is a static Url, without ? and parameters in the Url. You can use any unique value for that, like product name or page title.&lt;br /&gt;A permalink can look like this: http://www.5min.com/Video/What-is-5min%20XH9DUGl7fO8%3d.&lt;br /&gt;Then you need to generate the sitemap from a server page. You can use the XmlDocument object model to build the correct &lt;a href=&quot;https://www.google.com/webmasters/tools/docs/en/protocol.html#sitemapXMLFormat&quot;&gt;Xml file format&lt;/a&gt;. I suggest that you use an HttpHandler for this task, but any Asp page will do as well. All you need to do is to write the Xml file into the Http Response object.&lt;br /&gt;&lt;br /&gt;Now that you have the Sitemap ready, you have to submit it to google as your Sitemap. For this you have to register to the &lt;a href=&quot;www.google.com/webmasters/&quot;&gt;Google Webmaster Tool&lt;/a&gt; service. If you already have a Google account then it&#39;s enough. There you have simple instructions how to submit your Sitemap. You can submit many sites and see how google reads them and more statistics.&lt;br /&gt;&lt;br /&gt;You can find good information on Sitemaps at &lt;a href=&quot;http://www.sitemaps.org/&quot;&gt;http://www.sitemaps.org/.&lt;/a&gt;&lt;br /&gt;An already-made c# Sitemap class can be found &lt;a href=&quot;http://www.codeproject.com/cs/library/csharp_sitemap.asp&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Please comment with your opinion on this post.&lt;br /&gt;&lt;br /&gt;Benny.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/7181796679435054525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/7181796679435054525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7181796679435054525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/7181796679435054525'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/05/creating-and-submitting-sitemap-to.html' title='Creating and Submitting a Sitemap to Google'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-5911109044809422286</id><published>2007-04-22T07:11:00.000-07:00</published><updated>2007-04-22T07:42:14.678-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="debug"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="internet explorer"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio"/><title type='text'>Debugging Javascript in Visual Studio</title><content type='html'>Last week our server crashed, and had us roaming the internet with no purpose for a couple of days. Maybe one day I will write about that a separate post. The outcome of this is that all Internet Explorer definitions were reset when i connected to the new server and domain. &lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since then, i was unable to debug javascript in visual studio. It took me a while to verify that I&#39;m trying to debug the correct script and that the calling procedure is working fine. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I made sure that IIS was configured to debug asp pages, as you can see in the following pictures.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Inside the IIS console open the web site properties.&lt;br /&gt;&lt;a href=&quot;http://bp3.blogger.com/_u4nq3fR1ACc/RityVHAWhdI/AAAAAAAAAAw/Oswksk1JtuI/s1600-h/IISScriptDebugging1.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5056260713636857298&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp3.blogger.com/_u4nq3fR1ACc/RityVHAWhdI/AAAAAAAAAAw/Oswksk1JtuI/s400/IISScriptDebugging1.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;On the &quot;Virtual directory&quot; tab click on &quot;Configuration&quot;.&lt;br /&gt;&lt;a href=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rityg3AWheI/AAAAAAAAAA4/DiRUp65khfs/s1600-h/IISScriptDebugging2.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5056260915500320226&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rityg3AWheI/AAAAAAAAAA4/DiRUp65khfs/s400/IISScriptDebugging2.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the configuration dialog select the Debugging tab and check the two debugging flags.&lt;br /&gt;&lt;a href=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rityq3AWhfI/AAAAAAAAABA/T7Pw0paW97E/s1600-h/IISScriptDebugging3.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5056261087299012082&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp2.blogger.com/_u4nq3fR1ACc/Rityq3AWhfI/AAAAAAAAABA/T7Pw0paW97E/s400/IISScriptDebugging3.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;The last thing to check was Internet Explorer Options. In order to debug Javascript inside Visual Studio one must uncheck the (default) options that disable javascript debugging both on Internet Explorer and on other browsers. this is the checkbox to uncheck:&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://bp3.blogger.com/_u4nq3fR1ACc/RitvdHAWhcI/AAAAAAAAAAo/Y0GMm_-m5bk/s1600-h/ScriptDebugging.png&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5056257552540927426&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;http://bp3.blogger.com/_u4nq3fR1ACc/RitvdHAWhcI/AAAAAAAAAAo/Y0GMm_-m5bk/s400/ScriptDebugging.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Well, Now you can just break an any Javascript line, see all values inside the Visual Studio enviroment, and generally have fun while debugging your site :)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;benny is freely debugging javascript...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/5911109044809422286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/5911109044809422286' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5911109044809422286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5911109044809422286'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/04/debugging-javascript-in-visual-studio.html' title='Debugging Javascript in Visual Studio'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://bp3.blogger.com/_u4nq3fR1ACc/RityVHAWhdI/AAAAAAAAAAw/Oswksk1JtuI/s72-c/IISScriptDebugging1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-8616046869475208530</id><published>2007-04-22T01:20:00.000-07:00</published><updated>2007-04-22T01:27:22.762-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="browser"/><category scheme="http://www.blogger.com/atom/ns#" term="cache"/><category scheme="http://www.blogger.com/atom/ns#" term="iframe"/><category scheme="http://www.blogger.com/atom/ns#" term="query string"/><title type='text'>IFrame strikes back</title><content type='html'>Well, the IFrame bug from last post still exist, and we still don&#39;t know what to do about it.&lt;br /&gt;Some good news are that this bug now appears only seldom and we are less concerned about it. We created a random query string that we attached to this frame source url, to make sure that the browser really really really not caching the page. this way the browser thinks its a new page every time. This (at least we think so) lowered to frequency of appearance of the bug to reasonable levels. Yet, the mystery continues...</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/8616046869475208530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/8616046869475208530' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8616046869475208530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8616046869475208530'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/04/iframe-strikes-back.html' title='IFrame strikes back'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-5712998195680228302</id><published>2007-04-12T07:55:00.000-07:00</published><updated>2007-04-12T08:45:09.900-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cache"/><category scheme="http://www.blogger.com/atom/ns#" term="experts exchange"/><category scheme="http://www.blogger.com/atom/ns#" term="http"/><category scheme="http://www.blogger.com/atom/ns#" term="iframe"/><category scheme="http://www.blogger.com/atom/ns#" term="meta"/><category scheme="http://www.blogger.com/atom/ns#" term="sniffer"/><title type='text'>IFrame object loads wrong pages !?!?!</title><content type='html'>This is truly a bug from hell.&lt;br /&gt;&lt;br /&gt;For the last two days the upload page on our site behaves very strange. If it was not so creepy i would say the page is sick :-)&lt;br /&gt;this page includes an IFrame object that shows a second page inside, we will call them Outer page and Inner page.&lt;br /&gt;What happends is this: when entering the outer page we sometimes see the inner page correctly. Other times we see the inner page broken, and the source shows that not all page was loaded. Other times we see even stranger things: the inner page is partially loaded and a totally different page is appended to it&#39;s end, creating a total mess on the page.&lt;br /&gt;&lt;br /&gt;this bug appears only on our production server (dedicated, hosted) and not on our internal network. We tried to move the javascripts on the page around with no change. We tried putting a meta tag that prevents caching of the page - again nothing changed.&lt;br /&gt;&lt;br /&gt;We are going to try a sniffer on the response and compare it with the browser source, maybe something goes wrong while rendering this page.&lt;br /&gt;&lt;br /&gt;I have not fount any documentation of such a bug anywhere on the net. I still didn&#39;t get any answers from any newsgroup or from &lt;a href=&quot;http://www.experts-exchange.com/&quot;&gt;Experts Exchange&lt;/a&gt; (a great technical solution site). I&#39;m getting a little worried...&lt;br /&gt;&lt;br /&gt;If anyone ever encountered such a problem or has any suggestions i will be happy to hear it.&lt;br /&gt;I will keep rolling this story as it happends.&lt;br /&gt;&lt;br /&gt;Scratching my head :-)&lt;br /&gt;Benny.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/5712998195680228302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/5712998195680228302' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5712998195680228302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5712998195680228302'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/04/iframe-object-loads-wrong-pages.html' title='IFrame object loads wrong pages !?!?!'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-2541516740289050950</id><published>2007-04-12T01:23:00.000-07:00</published><updated>2007-04-12T01:46:06.749-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="flash"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="object"/><category scheme="http://www.blogger.com/atom/ns#" term="server"/><category scheme="http://www.blogger.com/atom/ns#" term="tag"/><title type='text'>Flash object fails to call Javascript function</title><content type='html'>&lt;a href=&quot;http://www.gortonstudios.com/sites/default/files/u1/flash_logo.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 54px; CURSOR: hand; HEIGHT: 59px&quot; height=&quot;54&quot; alt=&quot;&quot; src=&quot;http://www.gortonstudios.com/sites/default/files/u1/flash_logo.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; The most popular way to show video in web pages today is to play the video files inside flash players that are embedded inside the html page. Like everyone else we did it too and it works just fine.&lt;br /&gt;&lt;p&gt;A new feature that we added to our site is the ability to embed our flash player into any blog or site page, and for this purpose we also added a feature that sends information from the flash player to our server each time someone plays one of our videos somewhere out there. That way we can count how many views our videos get even outside the site.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;When we added this view-counter feature we could not get it to work. The flash player did not reach the server page even though we wrote the calling code properly.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;After looking at some professional blogs and sites we found out the problem: we use the name &quot;5minPlayer&quot; as our player tag name, and the Object tag that holds the flash player should not begin with a number...&lt;/p&gt;&lt;br /&gt;&lt;p&gt;There are other limitations to this object tag, and also many things you should know if you are going to use flash on your page, especially if you are implementing extensive interaction between flash and the html page. A great page on this issue can be found &lt;a href=&quot;http://www.permadi.com/tutorial/flashjscommand/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/2541516740289050950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/2541516740289050950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/2541516740289050950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/2541516740289050950'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/04/flash-object-fails-to-call-javascript.html' title='Flash object fails to call Javascript function'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-6900144547578472691</id><published>2007-03-21T05:15:00.000-07:00</published><updated>2007-03-21T06:17:30.025-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="browser ie internet explorer firefox request browsercapabilities"/><title type='text'>Browser Compatability</title><content type='html'>&lt;a href=&quot;http://static.flickr.com/9/15923400_bf9916f690.jpg&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 116px; CURSOR: hand; HEIGHT: 112px&quot; height=&quot;86&quot; alt=&quot;&quot; src=&quot;http://static.flickr.com/9/15923400_bf9916f690.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://z.about.com/d/websearch/1/0/n/3/bluee.png&quot;&gt;&lt;img style=&quot;FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 94px; CURSOR: hand; HEIGHT: 108px&quot; height=&quot;108&quot; alt=&quot;&quot; src=&quot;http://z.about.com/d/websearch/1/0/n/3/bluee.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;As we all know (and don&#39;t like it...) different browsers display HTML pages differently. We always work hard to make the pages we write to look good and the same in all browsers, or at least in the more popular ones. Some browsers that we will not mention their name (but they are made by microsoft) show HTML differently even between version. some not-very-sophisticated code works in one version and not in the other, especially new code is not backward competible.&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;There are two ways to tackle this situation. One is to write &quot;lower denominator code&quot;, HTML code that all browsers and versions treat the same, and avoiding code that the browsers show differently. This leaves us with a pretty basic subset of HTML, but it can be done for simpler pages.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;The second way is to write browser-specific code. something in the area of &quot;If IE then do this, else if Firefox do that&quot;. this should be done only in cases where there is no unified solution that include all browsers.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;In order to apply the second solution on the server side i suggest using these components and methods:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Create an Enum for all different supported browsers and version, something like that:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public enum Browsers&lt;br /&gt;{&lt;br /&gt;IE6,&lt;br /&gt;IE7,&lt;br /&gt;Firefox2,&lt;br /&gt;Safari1&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Create a function that recieves the BrowserCapabilities object included inside every HTTP request, and returns the specific browser and version as one of the Enum members:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;public Enums.Browsers GetBrowser(HttpBrowserCapabilities browserCap)&lt;br /&gt;{&lt;br /&gt;string strBrowser = browserCap.Browser;&lt;br /&gt;int majorVer = browserCap.MajorVersion;&lt;br /&gt;return (Enums.Browsers)Enum.Parse(typeof(Enums.Browsers), strBrowser + majorVer.ToString());&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Use this function to easily create switch cases to handle places that need different treatment for each browser: (In this case i use a negative margin to eliminate a blank area created in the original of a relatively-positioned Div element that includes an overlay image. This bug happends only in IE version 6)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;switch (utils.GetBrowser(Request.Browser))&lt;br /&gt;{&lt;br /&gt;case Enums.Browsers.IE6:&lt;br /&gt;divPlayImage.Style.Add(&quot;margin-bottom&quot;, (0- imgPlay.Height - 3).ToString() + &quot;px&quot;);&lt;br /&gt;break;&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Happy coding,&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;Benny.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/6900144547578472691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/6900144547578472691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/6900144547578472691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/6900144547578472691'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/03/browser-compatability.html' title='Browser Compatability'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-8884701903514962231</id><published>2007-03-16T02:43:00.000-07:00</published><updated>2007-03-16T02:53:05.384-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="duration length minutes seconds formatting"/><title type='text'>Formatting durations</title><content type='html'>As the internet gets filled with media files more and more sites need to display the duration of the audio/video file next to the file name and description. We store a file&#39;s play duration as a number of seconds in the database. In order to display the duration in a x:xx format we need to format it, using this small function:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;private string FormatDuration(short seconds)&lt;br /&gt;{&lt;br /&gt;string result = string.Empty;&lt;br /&gt;int minutes = seconds / 60;&lt;br /&gt;int secondsLeft = seconds % 60;&lt;br /&gt;result = minutes.ToString() + &quot;:&quot; + secondsLeft.ToString(&quot;00&quot;);&lt;br /&gt;return result;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/8884701903514962231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/8884701903514962231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8884701903514962231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/8884701903514962231'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/03/formatting-durations.html' title='Formatting durations'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-5742098682270606393</id><published>2007-03-15T01:44:00.000-07:00</published><updated>2007-03-15T01:59:38.280-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="array"/><category scheme="http://www.blogger.com/atom/ns#" term="parsing"/><category scheme="http://www.blogger.com/atom/ns#" term="split"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><category scheme="http://www.blogger.com/atom/ns#" term="tag"/><category scheme="http://www.blogger.com/atom/ns#" term="tags"/><title type='text'>Parsing tags input using Split function</title><content type='html'>User input validation is one of the more complex issues in developing a solid data-entry form. Input validation is the basis of application security, database integrity, application stability and more.&lt;br /&gt;&lt;br /&gt;Today i encountered an input validation issue regarding the input that users enter as &quot;tags&quot;, the popular new type of information used in many User Generated Content (UGC) sites.&lt;br /&gt;&lt;br /&gt;When i used the function Split from the String class to parse the tags into an array of strings i found out that if the user entered multiple space characters (eg. &quot;tag1 tag2    tag3&quot;) each space from the second one will result in an empty cell in the tags array. Splitting these sample tags will result in this array:&lt;br /&gt;array[0]: &quot;tag1&quot;&lt;br /&gt;array[1]: &quot;tag2&quot;&lt;br /&gt;array[2]: &quot;&quot;&lt;br /&gt;array[3]: &quot;&quot;&lt;br /&gt;array[4]: &quot;&quot;&lt;br /&gt;array[5]: &quot;tag3&quot;&lt;br /&gt;&lt;br /&gt;In order to avoid entering blank tags in the database i wrote a simple function that prepares a clean array of tags from the raw tags string. Here it is:&lt;br /&gt;(Besides removing empty cells this function also convert commas to blanks and lowers the case for all tags. This avoids multiple-word tags and case differences, as our project demands)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;private string[] PrepareTags(string tags)&lt;br /&gt;{&lt;br /&gt;char[] delim = { &#39; &#39; };&lt;br /&gt;//Replace comma with blank&lt;br /&gt;tags = tags.Replace(&quot;,&quot;, &quot; &quot;);&lt;br /&gt;//Split to array with blank delimiter&lt;br /&gt;string[] tagsArray = tags.Split(delim);&lt;br /&gt;ArrayList tagsList = new ArrayList();&lt;br /&gt;//Eliminate empty cells&lt;br /&gt;string[] preparedTags;&lt;br /&gt;for (int i = 0; i &lt; tagsArray.Length; i++)&lt;br /&gt;{&lt;br /&gt;if (tagsArray[i].Trim().Length &gt; 0)&lt;br /&gt;//Make all tags lowercase&lt;br /&gt;tagsList.Add((string)tagsArray[i].ToLower());&lt;br /&gt;}&lt;br /&gt;preparedTags = new string[tagsList.Count];&lt;br /&gt;tagsList.CopyTo(preparedTags);&lt;br /&gt;return preparedTags;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:times new roman;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:times new roman;&quot;&gt;If you find this function useful please comment and tell me.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/5742098682270606393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/5742098682270606393' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5742098682270606393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/5742098682270606393'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/03/parsing-tags-input-using-split-function.html' title='Parsing tags input using Split function'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7745129748420905494.post-1396429278112213744</id><published>2007-03-12T01:22:00.000-07:00</published><updated>2007-03-12T02:25:14.388-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax cache request response pragma"/><title type='text'>Cached Ajax Response</title><content type='html'>On my project i have a nice Upload wizard. It allows a user to write file information while the file is uploading. This page uses Ajax calls in order to communicate with the server while the file is still uploading.&lt;br /&gt;&lt;br /&gt;I had strange behaviour with this page...&lt;br /&gt;Sometimes it worked and sometimes not...&lt;br /&gt;While debugging i found out that if i upload the same file twice the second time fails.&lt;br /&gt;After placing breakpoints i found that the Ajax requests that fail never reach the server side.&lt;br /&gt;This fact gave me the idea that the response is being CACHED by the browser.&lt;br /&gt;&lt;br /&gt;In order to prevent Ajax requests from being cached by the browser i put these lines in my code before writing the response:&lt;br /&gt;&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.CacheControl = &quot;no-cache&quot;;&lt;br /&gt;Response.AddHeader(&quot;Pragma&quot;, &quot;no-cache&quot;);&lt;br /&gt;Response.Expires = -1;&lt;br /&gt;Response.ContentType = &quot;text/plain&quot;;&lt;br /&gt;&lt;br /&gt;This solved the problem entirly.&lt;br /&gt;&lt;br /&gt;P.S. If you are asking for static data using Ajax you may want it to be cached on the client to shorten response time. In that case don&#39;t use this code.</content><link rel='replies' type='application/atom+xml' href='http://bloodsweatandbugs.blogspot.com/feeds/1396429278112213744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/7745129748420905494/1396429278112213744' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/1396429278112213744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7745129748420905494/posts/default/1396429278112213744'/><link rel='alternate' type='text/html' href='http://bloodsweatandbugs.blogspot.com/2007/03/cached-ajax-response.html' title='Cached Ajax Response'/><author><name>Benyamin Shoham</name><uri>http://www.blogger.com/profile/06465751710166858952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT2IDY6_tnn8e1JChQadkK33WdUDYyLiF2nVHY8UdAPzg6ik3876bihr_vjavSZlYfZeQKUUM8eioP7bazt7tzoQMKvkC9P7LGRVE4j8aY5gBYJO0fzaAIvuMUoBxYB_E/s220/benny.shoham@gmail.com_5ee820d3.jpg'/></author><thr:total>3</thr:total></entry></feed>