<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>C#</title>
        <link>http://geekswithblogs.net/elroydsilva/category/8594.aspx</link>
        <description>C#</description>
        <language>en-US</language>
        <copyright>Elroy Dsilva</copyright>
        <managingEditor>elroydsilva@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>VSX Add-in Development Adventures: Window.Object returns NULL</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2009/08/29/vsx-add-in-development-adventures-window.object-returns-null.aspx</link>
            <description>&lt;p&gt;&lt;font size="3" face="Georgia"&gt;I’m in the middle of developing an add-in for Visual Studio 2008, a simple one that would help our in-house code review process. If you’ve ever written a VS add-in, you’d know the basic routine – Visual Studio creates the basic class &lt;font color="#408080"&gt;&lt;strong&gt;Connect&lt;/strong&gt;&lt;/font&gt; derived from &lt;font color="#408080"&gt;&lt;strong&gt;IDTExtensibility2&lt;/strong&gt;&lt;/font&gt;, then you put in your code in the methods OnConnection, OnDisconnection, OnAddInsUpdate, OnStartUpComplete and OnBeginShutdown.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Georgia"&gt;I developed a few user controls (UserControl objects) for showing some UI as tool windows. One of them was &lt;strong&gt;&lt;font color="#307376"&gt;AddCommentView&lt;/font&gt; &lt;/strong&gt;which is just a dumb UserControl that displays some textboxes and buttons and also takes in some input. I deployed this control as a separate DLL and linked it to the add-in. Then, as usual, the following code should do the job of creating the tool window.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/elroydsilva/WindowsLiveWriter/VSXAddindevelopmentWin.ObjectreturnsNULL_14473/AddCommentView.png" rel="lightbox"&gt;&lt;font face="Georgia"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="AddCommentView" border="0" alt="AddCommentView" src="http://geekswithblogs.net/images/geekswithblogs_net/elroydsilva/WindowsLiveWriter/VSXAddindevelopmentWin.ObjectreturnsNULL_14473/AddCommentView_thumb.png" width="815" height="199" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Georgia"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Georgia"&gt;And like always it worked just fine till I tried to test it and that’s when I realized something wasn’t quite right.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font face="Georgia"&gt;The &lt;font color="#408080"&gt;&lt;strong&gt;CreateToolWindow2&lt;/strong&gt;&lt;/font&gt; method has two outputs – the tool window (which is returned by the method) and the hosted user control (the ref parameter ‘objTemp’ in this case). The hosted user control can also be retrieved through the &lt;font color="#408080"&gt;&lt;strong&gt;Window.Object &lt;/strong&gt;&lt;/font&gt;&lt;font color="#000000"&gt;property of the returned tool window. The problem was – no matter what I tried the &lt;font color="#408080"&gt;&lt;strong&gt;Window.Object &lt;/strong&gt;&lt;font color="#000000"&gt;property always returned null and so did ‘objTemp’.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/elroydsilva/WindowsLiveWriter/VSXAddindevelopmentWin.ObjectreturnsNULL_14473/RetrieveValues.png" rel="lightbox"&gt;&lt;font face="Georgia"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="RetrieveValues" border="0" alt="RetrieveValues" src="http://geekswithblogs.net/images/geekswithblogs_net/elroydsilva/WindowsLiveWriter/VSXAddindevelopmentWin.ObjectreturnsNULL_14473/RetrieveValues_thumb.png" width="812" height="89" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face="Georgia"&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Georgia"&gt;The solution – I was acting dumb, very dumb. Visual Studio requires all hosted controls to be visible to COM. After adding the attribute to the entire assembly using &lt;strong&gt;[assembly: ComVisible(true)] , &lt;/strong&gt;everything started working like a charm (you can apply it even to the individual control if you don’t want to make the entire assembly COMVisible).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Georgia"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134377"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134377" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/134377.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2009/08/29/vsx-add-in-development-adventures-window.object-returns-null.aspx</guid>
            <pubDate>Sun, 30 Aug 2009 01:01:49 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/134377.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2009/08/29/vsx-add-in-development-adventures-window.object-returns-null.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/134377.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/134377.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 for Beginners - Extension Methods - Part 2</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2009/01/05/c-3.0-for-beginners---extension-methods---part-2.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128372"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128372" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/128372.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2009/01/05/c-3.0-for-beginners---extension-methods---part-2.aspx</guid>
            <pubDate>Tue, 06 Jan 2009 11:32:41 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/128372.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2009/01/05/c-3.0-for-beginners---extension-methods---part-2.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/128372.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/128372.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 for Beginners - Extension Methods - Part 1</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/11/06/c-3.0-for-beginners---extension-methods.aspx</link>
            <description>&lt;font size="2"&gt;           All C# code is eventually executed by the .NET CLR. This requires the C# compiler to transform the LINQ query expressions to a format that is understandable by .NET. LINQ query expressions are transformed into method calls, which are called &lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;extension methods&lt;/span&gt;. These methods are slightly different from normal methods. Lets discuss them in more detail:&lt;/font&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;font size="2"&gt;Consider the example that we saw in my previous posts. &lt;/font&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; GetIExplorer()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;1. Data Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;Process[] processes = Process.GetProcesses();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;2. Query Creation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;              &lt;/span&gt;&lt;span style="COLOR: blue"&gt;from&lt;/span&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; p.Id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;3. Query execution&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; pid &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; query)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Process Id : "&lt;/span&gt;+pid);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;font size="2"&gt;The query creation in part two transforms in a series of method calls on the data source '&lt;span style="FONT-WEIGHT: bold"&gt;processes&lt;/span&gt;' as follows.&lt;/font&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;            &lt;/span&gt;processes.Where(p =&amp;gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;                     &lt;/span&gt;.Select(p =&amp;gt; p.Id);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/address&gt;
&lt;br /&gt;
&lt;font size="2"&gt;The &lt;span style="FONT-WEIGHT: bold"&gt;Select &lt;/span&gt;clause, however, it not essential. It may be ignored and you might retrieve a list of processes and not their process Ids. The Select clause here specifies the entity to be selected in detail, in the above example, it was the process id belonging to the selected process.&lt;br /&gt;
&lt;br /&gt;
Now, you might wonder that since the &lt;span style="FONT-WEIGHT: bold"&gt;Where()&lt;/span&gt; method was called on the 'processes' Array, the Array object might have implemented the Where() method. But, that's not quite the case here. The method Where() is called an extension method and is used for extending a type's functionality.&lt;br /&gt;
&lt;br /&gt;
We have also made use of lambda expressions here. We will discuss their significance later in detail, but, for now, you can look at it as if it were a provision to select entities based in certain specified conditions. In the above code the variable 'p' indicates each element in the 'processes' array which is subjected to an expression evaluation &lt;span style="FONT-WEIGHT: bold"&gt;(p.ProcessName.ToLower().Equals("iexplore"))&lt;/span&gt;, and only if the result of the condition evaluation is true, will the item be selected as the result of the query. These are filtering expressions. &lt;br /&gt;
&lt;br /&gt;
In my next post I will describe how to define and use your own extension methods.&lt;/font&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126736"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126736" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126736.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/11/06/c-3.0-for-beginners---extension-methods.aspx</guid>
            <pubDate>Fri, 07 Nov 2008 06:29:13 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126736.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/11/06/c-3.0-for-beginners---extension-methods.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126736.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126736.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 for Beginners - Query Execution in LINQ</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/11/04/query-execution-in-linq.aspx</link>
            <description>&lt;p&gt;&lt;font size="2"&gt;       The execution of queries written is different from what a new LINQ user would perceive it to be. The query isn’t evaluated and the result is not stored in the query variable until the foreach iteration (where the values are actually required) or a manual iteration using the underlying GetEnumerator and MoveNext methods. The query variable only stores the query commands. This is concept is referred to as &lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;deferred execution&lt;/span&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;address&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;/address&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; GetIExplorer()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;   &lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;1. Data Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;Process&lt;/span&gt;[] processes = &lt;span style="COLOR: rgb(43,145,175)"&gt;Process&lt;/span&gt;.GetProcesses();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;2. Query Creation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span&gt;     &lt;/span&gt;from&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 1in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;where&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 1in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;select&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; p.Id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;3. Query execution&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;//&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(51,153,102); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;This is the part where the query is evaluated&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;//&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(51,153,102); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: red; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;and result is stored in the query variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; pid &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; query)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Process Id : "&lt;/span&gt;+pid);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;}&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal" style="FONT-FAMILY: Arial"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt; &lt;/p&gt;
&lt;link style="FONT-FAMILY: Arial" href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p&gt;&lt;font size="2"&gt;As the query variable doesn’t store the results, you can execute it as many times as you like. If a data source is updated at regular intervals, you could retrieve &lt;span style="FONT-WEIGHT: bold"&gt;the latest results&lt;/span&gt; every time you iterate over the query variable.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;img height="139" alt="Deferred execution" width="604" src="/images/geekswithblogs_net/elroydsilva/8932/o_Deferred execution.JPG" /&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The figure shown above shows information about the query variable ‘&lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;query&lt;/span&gt;’. The &lt;span style="FONT-WEIGHT: bold"&gt;Results View&lt;/span&gt; section shows the results of query execution and it also informs the user that “&lt;span style="FONT-WEIGHT: bold; FONT-STYLE: italic"&gt;Expanding the Results View will enumerate the IEnumerable&lt;/span&gt;” i.e. perform the query execution for debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;font size="3"&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Forcing immediate execution of queries&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;
    Immediate execution of queries is forced for queries that perform aggregation functions over the data retrieved from query evaluation. These functions include &lt;span style="FONT-WEIGHT: bold"&gt;Count&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold"&gt;Max&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold"&gt;Min&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold"&gt;Average &lt;/span&gt;etc. These queries execute without an explicit foreach statement because the query itself would use a foreach statement to calculate the result. &lt;br /&gt;
&lt;br /&gt;
The following query returns the number of processes identified as “IExplore.exe”.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;//&lt;span&gt;  &lt;/span&gt;Calculate the number of "iexplore" processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;int&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; numberOfProcesses = query.Count();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;font size="2"&gt;Execution results can be cached (if need be) for temporary processing using the ToList() and ToArray() methods as shown below:&lt;/font&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;//&lt;span&gt;  &lt;/span&gt;Caching results using ToList() and ToArray() methods.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(43,145,175); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;List&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; queryResult = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;(&lt;span style="COLOR: blue"&gt;from&lt;/span&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 1in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 1in"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;select&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; p.Id).ToList();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(43,145,175); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;Array&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; inferredQueryResult = &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;(&lt;span style="COLOR: blue"&gt;from&lt;/span&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt; &lt;/span&gt;select&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; p.Id).ToArray();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126603"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126603" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126603.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/11/04/query-execution-in-linq.aspx</guid>
            <pubDate>Wed, 05 Nov 2008 08:48:42 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126603.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/11/04/query-execution-in-linq.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126603.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126603.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 for Beginners - Learning LINQ - An Overview</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/11/03/learning-linq---an-overview.aspx</link>
            <description>&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Georgia;
	panose-1:2 4 5 2 5 4 5 2 3 3;
	mso-font-charset:0;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:647 0 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:951325141;
	mso-list-type:hybrid;
	mso-list-template-ids:-1102166076 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
	{mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I’m probably quite late to provide an overview on LINQ, which is by now a lot more popular than the time when I actually had started hearing about it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;Well, this is expected to be a series of posts that would help other rookies like me who haven’t yet started learning LINQ yet. So, lets get started. To begin with I’m providing here an overview of LINQ (Language Integrated Query).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;LINQ was introduced by Microsoft with the objective to reduce the complexity of accessing and integrating information. With the LINQ project, Microsoft has added query facilities to the .Net Framework that apply to all sources of information, not just relational or XML data. Everyday programmers write code that accesses a data source using looping and/or conditional constructs etc. The same constructs can be written using query expressions that are far lesser in code size. LINQ makes it possible to write easily readable and elegant code. The examples that follow will imply how easily understandable LINQ code can be. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-INDENT: 0.5in; TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;LINQ defines a set of standard query operators that you can use for traversal, filter and projection operations. These standard operators can be applied to any &lt;strong&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/strong&gt; based information source. The set of standard query operators can be augmented with new domain-specific operators that are more suitable for the target domain or technology. This extensibility in the query architecture is used in the LINQ project itself to provide implementations that work over both XML (LINQ to XML) and SQL (LINQ to SQL) data. Lets write some code to understand the query operators in more detail:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;link href="file:///C:%5CDOCUME%7E1%5CElroy%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 
  Normal
  0
  
  
  false
  false
  false
  
   
   
   
   
   
  
  MicrosoftInternetExplorer4
 
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Font Definitions */
 @font-face
	{
	panose-1:2 4 5 2 5 4 5 2 3 3;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;"Times New Roman";
	mso-fareast-"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-style-parent:"";
	font-size:10.0pt;"Times New Roman";}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Georgia;
	panose-1:2 4 5 2 5 4 5 2 3 3;
	mso-font-charset:0;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:647 0 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; System.Collections.Generic;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; System.Linq;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; System.Diagnostics;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; Using standard query operators.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; GetIExplorer()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;1. Data Source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;Process&lt;/span&gt;[] processes = &lt;span style="COLOR: rgb(43,145,175)"&gt;Process&lt;/span&gt;.GetProcesses();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;2. Query Creation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query = &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="MARGIN-LEFT: 2in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="COLOR: blue"&gt;where&lt;/span&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;                             &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; p.Id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: green"&gt;//&lt;span&gt;  &lt;/span&gt;3. Query execution&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; pid &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; query)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Process Id : "&lt;/span&gt;+pid);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;All LINQ query operations consist of three distinct operations:&lt;br /&gt;
&lt;br /&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;
&lt;ol style="MARGIN-TOP: 0in" type="1"&gt;
    &lt;li class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Identify the data source&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/li&gt;
    &lt;li class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Query creation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/li&gt;
    &lt;li class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Query execution&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Calling the method would show you the currently running Internet Explorer processes (their process ids). The heart of the method lies in the following statement of our program.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt; &lt;/p&gt;
&lt;link href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(43,145,175); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;IEnumerable&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query = &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; p &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; processes&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;                         where&lt;/span&gt; p.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;                         &lt;/span&gt;&lt;span style="COLOR: blue"&gt;select&lt;/span&gt; p.Id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The expression on the right hand side of this statement is called the &lt;strong&gt;query expression&lt;/strong&gt;. The output of this expression is held in the local variable ‘&lt;strong&gt;query’&lt;/strong&gt;. The query expression operates on one or more information sources by applying the query operators from the standard or domian specific set of query operators. We have used standard query operators here namely &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;where&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; and &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;select&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;The &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;from&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; clause select the list of processes which becomes the input for the &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;where&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; operator which filters the list and selects only those elements that satisfy the condition specified with the &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;where&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; operator. The selected elements are then processed by the &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;select&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; operator that determines any specific information selection for each element.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;The above statement can also be written using explicit syntax as shown below:&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt; &lt;/p&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: rgb(43,145,175); FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;IEnumerable&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&amp;gt; query = &lt;span style="COLOR: rgb(43,145,175)"&gt;Process&lt;/span&gt;.GetProcesses()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;               &lt;/span&gt;.Where(s =&amp;gt; s.ProcessName.ToLower().Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"iexplore"&lt;/span&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span&gt;               &lt;/span&gt;.Select(s =&amp;gt; s.Id);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: &amp;quot;Courier New&amp;quot;"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This form of query is called a method-based query and the arguments to the query operators are called &lt;strong&gt;lambda expressions&lt;/strong&gt;. They allow query operators to be defined individually as methods and are connected using the dot notation. I will deal with lambda expressions in my following posts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="TEXT-ALIGN: justify"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126575"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126575" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126575.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/11/03/learning-linq---an-overview.aspx</guid>
            <pubDate>Tue, 04 Nov 2008 10:25:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126575.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/11/03/learning-linq---an-overview.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126575.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126575.aspx</trackback:ping>
        </item>
        <item>
            <title>Anonymous methods in C#</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/11/02/anonymous-methods-in-c.aspx</link>
            <description>&lt;link href="file:///C:%5CDOCUME%7E1%5CElroy%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 
  Normal
  0
  
  
  false
  false
  false
  
   
   
   
   
   
  
  MicrosoftInternetExplorer4
 
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;
&lt;style&gt;
st1\:*{behavior:url(#ieooui) }
&lt;/style&gt;
&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Font Definitions */
 @font-face
	{
	panose-1:5 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;"Times New Roman";
	mso-fareast-"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{}
@list l0:level1
	{
	text-indent:-.25in;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-style-parent:"";
	font-size:10.0pt;"Times New Roman";}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;         An &lt;strong&gt;&lt;em&gt;anonymous method&lt;/em&gt;&lt;/strong&gt; is just a method that has no name. Anonymous methods are most frequently used to pass a code block as a delegate parameter.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div&gt;&lt;font size="2"&gt; &lt;span style="FONT-SIZE: 10pt"&gt;Before C# 2.0, the only way to declare a delegate was to use named methods as shown in the example below&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;address style="COLOR: rgb(51,153,102)"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;// Create the delegate&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;Display&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; message);&lt;/span&gt;&lt;/address&gt;
&lt;div style="COLOR: rgb(51,153,102)"&gt;
&lt;address&gt; &lt;/address&gt;
&lt;/div&gt;
&lt;div style="COLOR: rgb(51,153,102)"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;// Create the method&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; DisplayOnConsole(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; myMessage)&lt;/span&gt;&lt;/address&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;{&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(myMessage);&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;}&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt; &lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] args)&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;{&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: green"&gt;// Here, the delegate is instantiated with the&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    // method which should be invoked.&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: rgb(43,145,175)"&gt;Display&lt;/span&gt; myDisplay = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;Display&lt;/span&gt;(DisplayOnConsole);&lt;/span&gt;&lt;/address&gt;
&lt;div&gt;
&lt;address&gt; &lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: green"&gt;// Invoke&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    myDisplay(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Hello World!"&lt;/span&gt;);&lt;/span&gt;&lt;/address&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;}&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;Then C# 2.0 introduced the concept of anonymous methods.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div&gt; &lt;/div&gt;
&lt;address style="COLOR: rgb(51,153,102)"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;// Creation of delegate with an anonymous method&lt;/span&gt;&lt;/address&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Display&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; newDisplay = &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; msg)&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;{&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: green"&gt;// Anonymous method body&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(msg);&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;};&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt; &lt;/address&gt;
&lt;/div&gt;
&lt;div style="COLOR: rgb(51,153,102)"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;// Invoke&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;newDisplay(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Hello World using Anonymous methods."&lt;/span&gt;);&lt;/span&gt;&lt;/address&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt"&gt;The difference here is quite apparent. Creation of a new method to act as a handler is not required; the delegate itself specifies what should be done when invoked. Anonymous methods reduce the coding overhead in instantiating delegates because you do not have to create a separate method. Specifying a code bolck instead of a delegate can be useful in situations where creation another method might seem an unnecessary overhead.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;  &lt;br /&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 10pt"&gt;Some other points to remember:&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt; &lt;br /&gt;
&lt;/strong&gt;&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type="disc"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 10pt"&gt;There cannot be any jump statements like &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;goto&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;, &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;break&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; or &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;continue&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; inside the code block if the target is outside the block and vice versa. &lt;/span&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 10pt"&gt;The scope of parameters of an anonymous method is the anonymous code block. &lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 10pt"&gt;No &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;unsafe&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; code can be used within the anonymous code block.&lt;/span&gt; &lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 10pt"&gt;The local variables and parameters whose scope contains an anonymous method declaration are called &lt;strong&gt;&lt;em&gt;outer variables&lt;/em&gt;&lt;/strong&gt; of the anonymous method. In the following code the variable &lt;strong&gt;x&lt;/strong&gt; is an outer variable.&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div style="TEXT-INDENT: 0.5in"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;int&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; x = 0;&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="TEXT-INDENT: 0.5in"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Display&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt"&gt; newDisplay = &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; msg)&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="TEXT-INDENT: 0.5in"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;{&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="TEXT-INDENT: 0.5in"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;    &lt;span style="COLOR: rgb(43,145,175)"&gt;Console&lt;/span&gt;.WriteLine(msg + x);&lt;/span&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="TEXT-INDENT: 0.5in"&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;};&lt;/span&gt;&lt;/address&gt;
&lt;address&gt;&lt;span style="FONT-SIZE: 9pt"&gt;&lt;/span&gt;&lt;/address&gt;
&lt;span style="FONT-SIZE: 9pt"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;ul style="MARGIN-TOP: 0in" type="disc"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 10pt"&gt;An anonymous method cannot access the &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;ref&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; or &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt;out&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; variables of an outer scope.&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;  &lt;br /&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt"&gt;C# 3.0 introduces lambda expressions which are pretty much similar to anonymous methods but more expressive and concise. Applications written using .NET Framework version 3.5 and higher should make use of lambda expressions instead of anonymous methods. I will discuss lambda expressions in detail after I start with LINQ (Language Integrated Query) in my following posts.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126503"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126503" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126503.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/11/02/anonymous-methods-in-c.aspx</guid>
            <pubDate>Mon, 03 Nov 2008 10:23:24 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126503.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/11/02/anonymous-methods-in-c.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126503.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126503.aspx</trackback:ping>
        </item>
        <item>
            <title>Did you know the two uses of ‘default’?</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/did-you-know-the-two-uses-of-default.aspx</link>
            <description>&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CElroy%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 
  Normal
  0
  
  
  false
  false
  false
  
   
   
   
   
   
  
  MicrosoftInternetExplorer4
 
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;"Times New Roman";
	mso-fareast-"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-style-parent:"";
	font-size:10.0pt;"Times New Roman";}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p style="text-indent: 0.5in; text-align: justify;"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt;"&gt;Well, maybe you do and maybe you don’t. And I’m not trying to start a series of posts tagged “Did you know?”, I guess &lt;a href="http://blogs.msdn.com/saraford/"&gt;Sara Ford&lt;/a&gt; is much better at it. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt;"&gt;You’ve used the &lt;strong&gt;&lt;span style="color: blue;"&gt;default&lt;/span&gt;&lt;/strong&gt; keyword in C# as many times as possible in switch statements to indicate the default operation to be carried out. That’s one place where you would normally use the &lt;strong&gt;&lt;span style="color: blue;"&gt;default&lt;/span&gt;&lt;/strong&gt; keyword. &lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt;"&gt; &lt;br /&gt;
&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;You can also use the &lt;strong&gt;&lt;span style="color: blue;"&gt;default&lt;/span&gt;&lt;/strong&gt; keyword in generic code where it specifies the default value of the type parameter which is null for reference types and zero for value types. &lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;In generic programming it is always difficult to guess what default value to assign to a parameterized type T when you don’t know information such as whether T is a value/reference type; if it’s a value type, is it an elementary type or a struct? This is where the &lt;strong&gt;&lt;span style="color: blue;"&gt;default&lt;/span&gt;&lt;/strong&gt; keyword is used to find out the exact default value for the current type. Here is how it would be used:&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;class&lt;/span&gt;&lt;span style="font-size: 9pt;"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;MyGenerics&lt;/span&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;{&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; MyMethod()&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;    {&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;               T myVar = &lt;span style="color: blue;"&gt;default&lt;/span&gt;(T);&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;       &lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="margin-left: 0.5in;"&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt; &lt;span style="color: green;"&gt;//...&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div style="margin-left: 0.5in;"&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt; //...&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;address style="margin-left: 0.5in;"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;&lt;/span&gt;&lt;span style="font-size: 9pt;"&gt;int&lt;/span&gt;&lt;span style="font-size: 9pt;"&gt; defaultValue = &lt;span style="color: blue;"&gt;default&lt;/span&gt;(&lt;span style="color: blue;"&gt;int&lt;/span&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;    }&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;address&gt;&lt;font size="2"&gt;&lt;span style="font-size: 9pt;"&gt;}&lt;/span&gt;&lt;/font&gt;&lt;/address&gt;
&lt;/div&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt;"&gt;The default value for reference types is null, for value types is zero and for struct types each member is initialized with it’s default value depending on whether it is a value or reference type.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126433"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126433" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126433.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/did-you-know-the-two-uses-of-default.aspx</guid>
            <pubDate>Sat, 01 Nov 2008 07:22:58 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126433.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/did-you-know-the-two-uses-of-default.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126433.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126433.aspx</trackback:ping>
        </item>
        <item>
            <title>Conditional compilation in C#</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/conditional-compilation-in-c.aspx</link>
            <description>&lt;link rel="File-List" href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" /&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object
classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui&gt;&lt;/object&gt;
&lt;style&gt;
st1\:*{behavior:url(#ieooui) }
&lt;/style&gt;
&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;       Programmers need to debug, which sometimes requires identification of points in your program where a programmer would like to insert code that would help him/her to debug his/her code efficiently. A simple example might be inserting a Console.Writeline() call that prints out values or indicates completion (successful or unsuccessful) of the executed part. However, these lines can clutter up the code structure and also needs removal of the debugging code for the release of the entire software.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;            &lt;/span&gt;This overhead is taken care of by specialized methods in C# that help the programmer debug the code without the need to clean up his/her debugging code for the release phase. These methods which are used for debugging are called &lt;strong style=""&gt;&lt;em style=""&gt;Conditional methods&lt;/em&gt;&lt;/strong&gt;. The compiler identifies these marked methods and never includes them in the release build.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;            &lt;/span&gt;Well, that’s good enough. But, how do I make a method conditional? .NET provides an attribute &lt;strong style=""&gt;System.Diagnostics.ConditionalAttribute&lt;/strong&gt; (alias &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(43, 145, 175);"&gt;Conditional&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;) to achieve this. Let’s look at some code now.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;  &lt;/o:p&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span style="font-family: Arial;"&gt;Defining the conditional method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;strong style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;MyTracer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;[&lt;span style="color: rgb(43, 145, 175);"&gt;Conditional&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"DEBUG"&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; LogThisMessage(&lt;span style="color: blue;"&gt;string&lt;/span&gt; myMessage, &lt;span style="color: blue;"&gt;int&lt;/span&gt; severity)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: green;"&gt;//&lt;span style=""&gt;  &lt;/span&gt;Write message to screen or a file or ...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: rgb(163, 21, 21);"&gt;" DEBUG MESSAGE : "&lt;/span&gt; + myMessage &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="margin-left: 1.5in; text-indent: 0.5in;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;+&lt;span style="color: rgb(163, 21, 21);"&gt;" SEVERITY LEVEL : "&lt;/span&gt;+severity);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;The &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(43, 145, 175);"&gt;Conditional&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; attribute has been applied to the &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;LogThisMessage()&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt; method with the &lt;strong style=""&gt;DEBUG&lt;/strong&gt; conditional compilation symbol. This signals the compiler that the method should be ignored if the conditional symbol &lt;strong style=""&gt;DEBUG&lt;/strong&gt; is not specified. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;  &lt;br /&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;strong style=""&gt;&lt;span style="font-family: Arial;"&gt;Using the conditional method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;strong style=""&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;With the &lt;strong style=""&gt;Solution Configurations&lt;/strong&gt; set to Debug mode if you execute the following code, you would happily see the output window shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;public&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; &lt;st1:place w:st="on"&gt;Main&lt;/st1:place&gt;(&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: green;"&gt;//&lt;span style=""&gt;  &lt;/span&gt;Some error occured in my code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: green;"&gt;//&lt;span style=""&gt;  &lt;/span&gt;Log the message&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style=""&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MyTracer&lt;/span&gt;.LogThisMessage(&lt;span style="color: rgb(163, 21, 21);"&gt;"The error 1221 has occured."&lt;/span&gt;, 5);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/address&gt;
&lt;address class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 9pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;/address&gt;
&lt;p class="MsoNormal" style="text-align: center;"&gt; &lt;img alt="DEBUG on" src="/images/geekswithblogs_net/elroydsilva/8932/o_Conditional_Methods_DEBUG.JPG" style="width: 506px; height: 291px;" /&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Now lets see what happens to our conditional code in the Release mode. To enable Debug or Release mode you have to look for the Solution Configurations selector in your Visual Studio IDE which is shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: center;"&gt;&lt;img width="367" height="119" alt="" src="/images/geekswithblogs_net/elroydsilva/8932/o_Solution_Configurations_Mode.JPG" /&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;link rel="File-List" href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;Change the mode to &lt;strong style=""&gt;“Release” &lt;/strong&gt;and you would see that the conditional code now has disappeared.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: center;"&gt; &lt;img alt="" src="/images/geekswithblogs_net/elroydsilva/8932/o_Conditional_Methods_ReleaseMode.JPG" style="width: 563px; height: 318px;" /&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;We used the predefined &lt;strong style=""&gt;DEBUG&lt;/strong&gt; compilation symbol in our code. You can have your own defined symbols and use them for conditional compilation. You can define custom compilation symbols in Project Properties -&amp;gt; Build tab -&amp;gt; General. Checkboxes have been provided to enable or disable the &lt;strong style=""&gt;DEBUG&lt;/strong&gt; and &lt;strong style=""&gt;TRACE&lt;/strong&gt; symbols.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: center;"&gt; &lt;img alt="" src="/images/geekswithblogs_net/elroydsilva/8932/o_ProjectProperties_Build_ConditionalSymbols.JPG" style="width: 554px; height: 152px;" /&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;  &lt;br /&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt; &lt;/p&gt;
&lt;link rel="File-List" href="file:///C:\DOCUME~1\Elroy\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" /&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" LatentStyleCount="156"&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;style type="text/css"&gt;&lt;!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:959648263;
	mso-list-type:hybrid;
	mso-list-template-ids:1928770922 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:;
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--&gt;&lt;/style&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
&lt;/style&gt;
&lt;![endif]--&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;.NET also provides two classes that provide similar functionality:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul type="disc" style="margin-top: 0in;"&gt;
    &lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;System.Diagnostics.Debug&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;System.Diagnostics.Trace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;These classes contain methods that can also be used for debugging if you do not need more specific custom methods.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126430"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126430" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/126430.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/conditional-compilation-in-c.aspx</guid>
            <pubDate>Sat, 01 Nov 2008 06:55:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/126430.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/10/31/conditional-compilation-in-c.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/126430.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/126430.aspx</trackback:ping>
        </item>
        <item>
            <title>Covariance and Contravariance in delegates</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/10/22/covariance-and-contravariance-in-delegates.aspx</link>
            <description>If you’ve used delegates while programming you probably know about covariance and contravariance in delegates that provide a degree of flexibility when you match method signatures with delegate types. &lt;a href="http://geekswithblogs.net/elroydsilva/archive/2008/10/22/covariance-and-contravariance-in-delegates.aspx"&gt;Read More...&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125996"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125996" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/125996.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/10/22/covariance-and-contravariance-in-delegates.aspx</guid>
            <pubDate>Thu, 23 Oct 2008 02:29:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/125996.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/10/22/covariance-and-contravariance-in-delegates.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/125996.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/125996.aspx</trackback:ping>
        </item>
        <item>
            <title>Efficient XML processing</title>
            <link>http://geekswithblogs.net/elroydsilva/archive/2008/08/27/smarter-xml-processing.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;     Nowadays, many developers deal with a lot of XML files everyday. These files can be anything ranging from uses in configuration, documentation, databases where they are used for data sharing, data transport or simplifying platform changes. These files can grow to a very large size and need to be processed in an optimized way.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;For example, while reading a configuration file, the module that reads the XML, iteratively reads the XML tag for the current XML Element and decides what processing it then has to do. A relatively large XML file would then contain a lot of different XML Elements(differed by their tags) that need to be checked each time you encounter an XML Element.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;A brute force algorithm ro achieve this would be to check for each XML tag by doing a string comparison using an if-else ladder. For now, your XML file contains just three tags - Config1, Config2 and Config3. Your code would look something like this:&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;class&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;Caller&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;    {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;         public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Call(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: green"&gt;// Using the if-else ladder&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt;(inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config1"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                Method1();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt;(inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config2"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                Method3();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt;(inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config3"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                Method2();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;    }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;All works well. But, what if the number of XML tags that need to be handled grow each day. You will be handling "Config1" to "ConfigN" in the same way as you have did before - using the if-else ladder. And what if you have no control over the value of 'N'. That is when the processing time for each file increases and a need arises to check the efficiency of the code. String comparisons do take a lot of time and having so many string comparisons can ruin your code in terms of efficiency, maintablility and scalability. &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;If you try to visualize the above code in terms of a map, you would see that:&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;"Config1" maps to Method1()&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;"Config2" maps to Method2()&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;and so on...&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Here's when you know that it would be useful to modify your code to utilize the Hashtable class. Initialize the Hashtable object to store the &amp;lt;key, value&amp;gt; pair as &amp;lt;string, MethodHandlerDelegate&amp;gt; where the string object represents the XML tag input such as "Config1", "Config2" and so on... and the MethodHandlerDelegate is a delegate type that references the method that needs to be called. This can be done using an initializer method such as:&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        private&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;SortedDictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;&amp;gt; stringToDelegateDict;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;         public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; Caller()&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            stringToDelegateDict = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;SortedDictionary&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;, &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;&amp;gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;         public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Initialize()&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; handler1 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;(Method1);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; handler2 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;(Method2);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; handler3 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt;(Method3);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            Add&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 11pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;Handler&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; (&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config1"&lt;/span&gt;, handler1);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            Add&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 11pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;Handler&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; (&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config2"&lt;/span&gt;, handler2);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;Add&lt;/span&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 11pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;Handler&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; (&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config3"&lt;/span&gt;, handler3);&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: green; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;             // All the handler methods are initialized here in the SortedDictionary.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Note that we use a SortedDictionary object here since we are aware of the types of the key and value that might be inserted into the Dictionary. This saves us from doing any unnecessary downcasting which we would need to do if we used a Hashtable.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Using this approach, it can also be decided at runtime that which of the handlers need be present in the dictionary by using the following methods that add or remove a handler from the dictionary.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Now, you can subscribe the handlers only when they will be needed. &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: green; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;       // Adding a new handler&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; AddHandler(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue, &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; handler)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            stringToDelegateDict.Add(inputValue, handler);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        &lt;span style="COLOR: green"&gt;// Removing an existing handler&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RemoveHandler(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            stringToDelegateDict.Remove(inputValue);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;When you encounter an XML tag now, use just make the same call that you did earlier like this:&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: rgb(43,145,175); FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;         Caller&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; c = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: rgb(43,145,175)"&gt;Caller&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        c.Initialize();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        c.Call(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Input1"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        c.Call(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Input2"&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;However, you change your Call method to have the following implementation.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;         public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Call(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;             &lt;span style="COLOR: green"&gt;// Get the delegate to the respective method.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; mh = stringToDelegateDict[inputValue];&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: green; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;             // Make the call.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            mh();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;This definitely makes life simple while dealing with changes in the XML tags, adding handlers for new tags, removing handlers for existing tags and providing the runtime support for the same. Now, any changes occuring to the XML format would need changes in the Caller.Initialize method. Here, the method handlers act as subscribers that can dynamically subscribe/unsubscribe for a particular event.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Now, what if your design says that it needs to call both Method1 and Method2 to handle the tag “Config1”? In case you were using the OrdinaryCaller design, you would handle it something like this:&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: blue; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; &lt;/span&gt;&lt;font size="2"&gt;&lt;span style="FONT-SIZE: 11pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;CallModified&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue)&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: green"&gt;// Using the if-else ladder&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config1"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: rgb(43,145,175)"&gt;Handler&lt;/span&gt;.Method1();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: rgb(43,145,175); FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                Handler&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;.Method2();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config2"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: rgb(43,145,175)"&gt;Handler&lt;/span&gt;.Method2();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (inputValue.Equals(&lt;span style="COLOR: rgb(163,21,21)"&gt;"Config3"&lt;/span&gt;))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: green"&gt;// The OrdinaryCaller.Call method needs to be changed like this.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: rgb(43,145,175)"&gt;Handler&lt;/span&gt;.Method3();&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;The problem with doing this is that you need to keep changing the code of the Call() method and also the main disadvantage is that you cannot change the behaviour of the Call() method at runtime.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Here is where the concept of multicast delegates comes into picture. You slightly modify the AddHandler() method to support multicast delegates. This let you have any number of delegate methods as handlers of each tag.&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: green; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;// Adding a new handler&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; AddHandler(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; inputValue, &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; handler)&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: green"&gt;// Check if the string key is already available...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (stringToDelegateDict.ContainsKey(inputValue))&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: green"&gt;// If yes, create a multicast delegate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: green"&gt;// and place it back there with the same key.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: rgb(43,145,175)"&gt;MethodHandler&lt;/span&gt; temp = stringToDelegateDict[inputValue];&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                temp += handler;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                stringToDelegateDict.Remove(inputValue);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                stringToDelegateDict[inputValue] = temp;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                &lt;span style="COLOR: green"&gt;// else, simply add the handler.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;                stringToDelegateDict.Add(inputValue, handler);&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; FONT-FAMILY: 'Courier New'; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Georgia"&gt;Just call the AddHandler() method to subscribe a new handler and voila! You’ve got another handler working right where you wanted it.
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt"&gt;I felt that the above mentioned technique is just a better way of handling large XML files. I’m sure more cleaner options exist to do the same which I’m not aware of. What do you think? What can be a better and more efficient technique to do this?&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt; &lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fgeekswithblogs.net%2felroydsilva%2farchive%2f2008%2f08%2f27%2fsmarter-xml-processing.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" border="0" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fgeekswithblogs.net%2felroydsilva%2farchive%2f2008%2f08%2f27%2fsmarter-xml-processing.aspx" /&gt;&lt;/a&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124718"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124718" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/elroydsilva/aggbug/124718.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Elroy Dsilva</dc:creator>
            <guid>http://geekswithblogs.net/elroydsilva/archive/2008/08/27/smarter-xml-processing.aspx</guid>
            <pubDate>Thu, 28 Aug 2008 02:13:10 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/elroydsilva/comments/124718.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/elroydsilva/archive/2008/08/27/smarter-xml-processing.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/elroydsilva/comments/commentRss/124718.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/elroydsilva/services/trackbacks/124718.aspx</trackback:ping>
        </item>
    </channel>
</rss>