<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>D Melodic Minor Accidental : Random .NET Platform</title><link>http://blogs.msdn.com/theoy/archive/tags/Random+.NET+Platform/default.aspx</link><description>Tags: Random .NET Platform</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>"Find All References" Design, regarding interface members</title><link>http://blogs.msdn.com/theoy/archive/2005/07/06/436254.aspx</link><pubDate>Thu, 07 Jul 2005 01:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:436254</guid><dc:creator>TheoY</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/theoy/comments/436254.aspx</comments><wfw:commentRss>http://blogs.msdn.com/theoy/commentrss.aspx?PostID=436254</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;One of the things that I've been working on to help finish Whidbey, are the new refactoring features.&amp;nbsp; However, I've recently found myself questioning the design for "Find All References", in regards to its handling of interface members.&amp;nbsp; I discovered this behavior while writing a toy project in C#, but the following example illustrates it better, in my opinion.&amp;nbsp; Imagine you're writing a generalized library - and provide two different interfaces, IResource and IStream.&amp;nbsp; Both of them have the notion of a Close() method (for simplicity sake, I'll put&amp;nbsp;the interfaces&amp;nbsp;in separate files, which will help make it easier to see the design confusion):&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;interface&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;IResource&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;BR style="mso-special-character: line-break"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;o:p&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;interface&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;IStream&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;Simple enough, right? The conundrum arises when you have an object that implements both interfaces, &lt;STRONG&gt;and&lt;/STRONG&gt; uses the the same member to implement them, such as the following:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;BR&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: teal"&gt;NetworkSocket&lt;/SPAN&gt; : &lt;SPAN style="COLOR: teal"&gt;IResource&lt;/SPAN&gt;, &lt;SPAN style="COLOR: teal"&gt;IStream&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Close() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;BR style="mso-special-character: line-break"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;What struck &lt;EM&gt;me&lt;/EM&gt; as awkward, is that if you then&amp;nbsp;do "Find All References", on IStream.Close(), you'll get the following results:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) NetworkSocket.cs - (5,17): public void Close() {&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) IResource.cs - (5, 14): void Close();&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) IStream.cs - (5, 14): void Close();&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Thus, intellisense reports that IStream.Close() is defined in all of those three places.&amp;nbsp; However, &lt;EM&gt;why is IResource.Close() in this list&lt;/EM&gt;?&amp;nbsp; Some IDE-team members argue that the design was that we would return the &lt;EM&gt;transitive closure&lt;/EM&gt; of all of the methods that are captured during this find process.&amp;nbsp; I, however, argue that this is definitely unintuitive.&amp;nbsp; This gets worse too, for example, introduce the following:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: teal"&gt;OtherResource&lt;/SPAN&gt; : &lt;SPAN style="COLOR: teal"&gt;IResource&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Close() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;o:p&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: teal"&gt;OtherStream&lt;/SPAN&gt; : &lt;SPAN style="COLOR: teal"&gt;IStream&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Close() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: white; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.45pt 5.75pt 1.45pt 5.75pt; mso-yfti-tbllook: 480; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.75pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.75pt; PADDING-BOTTOM: 1.45pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1.45pt; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; Library;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: teal"&gt;StreamReader&lt;/SPAN&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; StreamReader(&lt;SPAN style="COLOR: teal"&gt;OtherStream&lt;/SPAN&gt; stream) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// ...read the stream ...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;stream.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Verdana size=2&gt;Now, invoke "Find All References" on &lt;STRONG&gt;IResource&lt;/STRONG&gt;.Close(). You'll get the following results:&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) NetworkSocket.cs - (5,17): public void Close() {&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) OtherResource.cs - (5,17): public void Close() {&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) OtherStream.cs - (5,17): public void Close() {&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Reference) StreamReader.cs - (6, 16) : stream.Close();&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) IResource.cs - (5, 14): void Close();&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;(Definition) IStream.cs - (5, 14): void Close();&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;IStream.Close() is on the list (which is the reverse case of the previous "strange" element), but what &lt;EM&gt;really&lt;/EM&gt; makes me think this is wrong, is that StreamReader's use of OtherStream is there.&amp;nbsp; OtherStream doesn't even implement IResource, so it's impossible for OtherStream.Close() to be related to IResource.Close().&amp;nbsp; In that context, you *know* you're &lt;STRONG&gt;not&lt;/STRONG&gt; dealing with an IResource, however, it's still a reference &amp;lt;shrug&amp;gt;.&amp;nbsp; This gets worse as you have more types that implement IResource or IStream, because whenever you do Find All References on Close(), you get even more unexpected results to wade through.&lt;BR&gt;&lt;BR&gt;So, you wonder, is there any&amp;nbsp;method behind the madness? It's all about Rename refactoring.&amp;nbsp; If you rename IStream.Close() to something else, you better rename IResource.Close() to the same thing, otherwise the NetworkSocket class will suddenly no longer implement all the members of IResource.&amp;nbsp; I think that's a valid concern, but IMHO, if you're sharing implementations on the same member, and then you rename one of the interfaces's declaration of that member, then I would &lt;STRONG&gt;expect&lt;/STRONG&gt; a compiler error to be introduced, saying that you can no longer implement both interfaces with the same member now.&amp;nbsp; Just because&amp;nbsp;one developer&amp;nbsp;happens to implement my interface, and someone else's interface, doesn't mean that if someone else renames their interface member that &lt;STRONG&gt;&lt;EM&gt;I too&lt;/EM&gt;&lt;/STRONG&gt; should be renamed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;So, mine is obviously a directed perspective, but how do the rest of you out there feel about this?&lt;/FONT&gt;&lt;/o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=436254" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/theoy/archive/tags/OO+Design+101/default.aspx">OO Design 101</category><category domain="http://blogs.msdn.com/theoy/archive/tags/Random+.NET+Platform/default.aspx">Random .NET Platform</category><category domain="http://blogs.msdn.com/theoy/archive/tags/C_2300_+IDE/default.aspx">C# IDE</category></item><item><title>Referring to "value types" versus "reference types", Part 2</title><link>http://blogs.msdn.com/theoy/archive/2005/06/28/ValueRef2.aspx</link><pubDate>Tue, 28 Jun 2005 23:31:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:433163</guid><dc:creator>TheoY</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/theoy/comments/433163.aspx</comments><wfw:commentRss>http://blogs.msdn.com/theoy/commentrss.aspx?PostID=433163</wfw:commentRss><description>&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT face=Verdana color=#000000 size=2&gt;Last Friday, I blogged about confusion between the terms "value" and "reference", when relating to .NET development.&amp;nbsp; The post can be found here:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="http://blogs.msdn.com/theoy/archive/2005/06/24/ValueRef.aspx"&gt;&lt;FONT face=Verdana size=2&gt;http://blogs.msdn.com/theoy/archive/2005/06/24/ValueRef.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This time, I'm continuing the discussion specifically relating to &lt;STRONG&gt;value types&lt;/STRONG&gt; and &lt;STRONG&gt;reference types&lt;/STRONG&gt;.&amp;nbsp; After this, passing by value / passing by reference will be covered, as well as referring to an object's "value" or its "reference". So, continuing... I left off stating that I still have the following topics to cover, as part of &lt;EM&gt;Referring to "value types" versus "reference types"&lt;/EM&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(1) Enums&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(2) Type unification, boxing/unboxing&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(3) Interfaces and inheritance for value types&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Enums&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;.NET has built-in support for a special kind of type, called an &lt;EM&gt;enum type&lt;/EM&gt;.&amp;nbsp; Enums are also value types, and have all of the traits that I described for value types in the previous blog entry, except for some&amp;nbsp;small differences that are not relevant to this topic.&amp;nbsp; One way to look at them is as &lt;EM&gt;specialized&lt;/EM&gt; value types.&amp;nbsp; For example, .NET enum types don't have instance fields, nor methods or&amp;nbsp;properties.&amp;nbsp; Basically they exist so that one can specify names for what would otherwise be numeric values.&amp;nbsp; Their syntax is as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face=Verdana color=#000000 size=2&gt;C#/J#:&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face=Verdana size=2&gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;enum&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt; &lt;FONT color=#008080&gt;MyEnumType&lt;/FONT&gt; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;VB.NET (requires all&amp;nbsp;enum types define at least one value):&lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Enum&lt;/FONT&gt; MyEnumType&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OneSampleValue&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face=Verdana size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT face=Verdana&gt; &lt;FONT color=#0000ff&gt;Enum&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Each of the languages will automatically assign values to the enums if you don't care, but also will let you define specific values to assign to their corresponding names if you wish.&amp;nbsp; As you'd expect, they all compile down to the same thing under the hood, which is one of the reasons why .NET language integration is so streamlined between C#/VB/J#.&amp;nbsp; However, when contrasting value types and reference types, a user only needs to know that enums are in the "value types" camp.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Type Unification, Boxing and Unboxing&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is when it gets a little hairy... so in the first article, I described value types getting allocated on the stack, and reference types on the heap.&amp;nbsp; However, there are some leftover questions that you're probably pondering, such as:&lt;BR&gt;&lt;BR&gt;(1) If anything that &lt;STRONG&gt;doesn't&lt;/STRONG&gt; extend from System.ValueType is a reference type, then how does the CLR tell the difference between value types and the rest of the types that descend directly/indirectly from System.Object?&lt;BR&gt;(2) How do value types implement interfaces, and how are those interface implementations distinguished between those of reference types?&lt;BR&gt;(3) Is System.ValueType itself, a value type or a reference type?&lt;BR&gt;&lt;BR&gt;Those are all good questions, and require understanding of the CLR type unification system.&amp;nbsp; Java has less of this to worry over, since it doesn't support custom value types (it only supports its built-in "primitive types").&amp;nbsp; In fact, prior to Java 1.5/5.0, users had to explicitly convert their primitive types to their corresponding wrapper objects (e.g. java.lang.Integer).&amp;nbsp; In addition, users of reflection on Java would have to deal with two different class objects for each primitive and its corresponding wrapped type.&amp;nbsp; Not fun.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Thus for .NET, there came a need to unify this more - and they introduced a concept of boxing and unboxing.&amp;nbsp; You can think of boxing and unboxing as being another special form of copying, for a value type (in fact, one &lt;EM&gt;must&lt;/EM&gt; realize that boxing and unboxing performs copies).&amp;nbsp; However, the distinction between boxing and unboxing from other forms of copying (say assignment, parameter passing or receiving return value) is that boxing places a value type inside a wrapper (a "box") where it *then* behaves like a &lt;STRONG&gt;heap object&lt;/STRONG&gt;.&amp;nbsp; By wrapping value types&amp;nbsp;as heap objects, they can then be treated the same way as other heap objects.&amp;nbsp;&amp;nbsp;.NET has built-in support for&amp;nbsp;object-oriented type systems - and likewise has to implement virtual methods similar to pre-.NET C++, and Java.&amp;nbsp; You probably guessed that virtual methods require some sort of special handling, that makes them different from non-virtual methods.&amp;nbsp; Since any subclass an override a non-sealed virtual method, there needs to be some infrastructure to look up which function to actually run.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The way that those usually work is that an object in memory usually has a pointer (just an address value to some other chunk of memory) that points back to a shared virtual method table (or &lt;EM&gt;v-table&lt;/EM&gt;), since in .NET and Java, overriding a method overrides it for all instances of that type.&amp;nbsp; Then the object can be passed around as any super type that it implements, and when a function call is required, a lookup of the appropriate index in the v-table will allow for code to pick up the overriden method.&amp;nbsp; As long as the means to access the v-table pointer are consistent, and the indices are consistent, then a function for one type need not worry about if it is executing on object that's actually an instance of a subclass.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is all fine and dandy, but once you're passing around pointers to objects, and you're trying to avoid examining what type they really are, then how do you know if you're dealing with an implementation derived from a value type, or a reference type? The answer is, by default, &lt;STRONG&gt;you don't&lt;/STRONG&gt;.&amp;nbsp; That's why value types &lt;STRONG&gt;&lt;EM&gt;need&lt;/EM&gt;&lt;/STRONG&gt; to be boxable into heap objects, so that code that consumes any interfaces that they implement may be able to dispatch off of those objects without having to concern themselves on whether or not that object is a value type or reference type.&amp;nbsp; Thus, it makes things easier to realize that when dealing with objects at an interface type-level, you're always dealing with heap objects - either reference type objects, or boxed value type objects.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The reason why I discuss "unification" is that in .NET, this wrapped value type support is automatically generated for you whenever you define a new value type.&amp;nbsp; It would be a nightmare if each user had to define their own heap wrapper type for every new value type they defined.&amp;nbsp; That's why Java's explicit type wrappers aren't a scalable solution if they were to allow users to define their own primitives.&amp;nbsp; Also, when using reflection, boxed and unboxed value types share the same type object (e.g. if you use C#'s typeof() keyword).&amp;nbsp; This means that if you're dealing with boxed or unboxed objects using reflection, you can confidently know that testing them against a type object will do what you'd expect (another issue with Java's having two separate class objects for wrapped and unwrapped primitives).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The last tricky part is that the type,&amp;nbsp;System.ValueType &lt;EM&gt;itself&lt;/EM&gt;, is &lt;STRONG&gt;not&lt;/STRONG&gt; a value type.&amp;nbsp; Users can only create objects of types that &lt;EM&gt;derive&lt;/EM&gt; from System.ValueType, and using a value type as an instance of System.ValueType causes it to be boxed.&amp;nbsp; The reason why is that once you're dealing with a value type at the System.ValueType level, you have very little knowledge remaining about the value type (for example, you have no idea what fields it has).&amp;nbsp; All you have are virtual methods that you can call, which require boxing, as you'd expect.&amp;nbsp; The same thing applies to System.Enum - once you're dealing with an enum value at the System.Enum level, you're actually dealing with a &lt;EM&gt;boxed enum&lt;/EM&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As you can tell, System.ValueType and System.Enum have to be special-cased in the runtime, as their descendents are all value types.&amp;nbsp; In my opinion, there's not really a great way to structure them in the inheritance tree, but here's how they're structured in reality: (go, go, ascii art)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#000000&gt;System.&lt;/FONT&gt;&lt;FONT color=#008080&gt;Object&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+- &lt;FONT color=#000080&gt;&lt;FONT face=Verdana color=#008080&gt;&lt;STRONG&gt;&lt;FONT color=#000000&gt;System.&lt;/FONT&gt;ValueType&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;+- &lt;FONT face=Verdana color=#008080&gt;&lt;STRONG&gt;&lt;FONT color=#000000&gt;System.&lt;/FONT&gt;Enum&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;+- &lt;FONT face=Verdana color=#000080&gt;&lt;STRONG&gt;&amp;lt;all enum-types&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;+- &lt;FONT face=Verdana color=#000080&gt;&lt;STRONG&gt;&amp;lt;all-non-enum-value-types&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+- &lt;/FONT&gt;&lt;FONT face=Verdana color=#008080&gt;&lt;STRONG&gt;&amp;lt;all-other-reference-types&amp;gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT face=Verdana size=2&gt;I use VS 2005 (Beta2 is pretty stable) when I code, and one of the things that I always change first is the fonts and colors preferences.&amp;nbsp; I set VS to colorize all enums and value types in navy, instead of teal, so that I can notice what my code is doing, and whether or not I'm going to copy, box, or&amp;nbsp;unbox.&amp;nbsp; As you can see, I've actually colorized the types System.ValueType and System.Enum in teal, because those types specifically, are actually reference types.&amp;nbsp; It's their derived types that are value types.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Interface inheritance for Value types&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Users defining their own value types will notice that they can specify interfaces for their value types to implement.&amp;nbsp; Yes, this is a powerful corollary to the unification described previously.&amp;nbsp; When transferred to a context that requires an interface to be implemented, value types get boxed, and are then indistinguishable from reference types, to the interface consumers.&amp;nbsp; What I mean by indistinguishable is that consumers needn't worry if they're dealing with value types or reference types - but they can of course query if the object in question also extends from System.ValueType (e.g. in C#, using the "is"/"as" keyword).&lt;/P&gt;
&lt;P&gt;I think that pretty well summarizes most of the important differences between value types and reference types.&amp;nbsp; In the queue of topics to cover in my future blog posts will be some best-practices for value types.&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=433163" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/theoy/archive/tags/Random+.NET+Platform/default.aspx">Random .NET Platform</category></item><item><title>Comparing C# and VB.NET</title><link>http://blogs.msdn.com/theoy/archive/2005/06/20/430838.aspx</link><pubDate>Mon, 20 Jun 2005 23:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:430838</guid><dc:creator>TheoY</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/theoy/comments/430838.aspx</comments><wfw:commentRss>http://blogs.msdn.com/theoy/commentrss.aspx?PostID=430838</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A reader wrote me just now:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#a52a2a size=2&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#a52a2a size=2&gt;I just came across your blog and seeing that you're mentioning random thoughs on .NET, I was hoping you'd be able to answer this question: Is there any real difference to coding in VB or in C# when it comes to the .NET framework? If there are differences, do they still exist when I narrow the topic down to .NET web applications?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#a52a2a size=2&gt;Thanks,&lt;BR&gt;Max&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;When it comes down to it, in my opinion, there aren't many significant language differences between VB.NET and C#.&amp;nbsp; Most of the constructs in those languages are achievable from the other language, which is why you'll often see samples online in both languages.&amp;nbsp; I think VB.NET includes more implicit conversion operators, as well as a bunch of other constructs if you disable option-strict compiling (such as late-binding).&amp;nbsp; C#, as a language, will generally be more explicit than VB.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;With VS 2005 (C# 2.0), C# includes anonymous methods, which are not a VB construct - VB users can workaround it by declaring new types/methods as necessary (which is what the C# compiler does under the hood).&amp;nbsp; C# 2.0 also supports new iterator methods (using the yield keyword), which I think is unsupported by VB.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;VB includes a ton of "built-in" functions, which usually delegate to other .NET framework library functions that are accessible by C#.&amp;nbsp; Because of that, VB programs load several .NET framework DLL's that are not always needed in all programs, but are required for supporting VB built-in functions.&amp;nbsp; In C#, a lot of what the language does to supplement the .NET Framework isn't providing specific built-in functions per se, but more language features, that affect the way your code is compiled (instead of introducing other dependencies).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In regards to ASP.NET and web applications, I don't think that the above discussion applies any differently - the ASP.NET integration should be nearly identical for both languages.&amp;nbsp; Any preference towards choosing VB over C# or vice versa will probably be off of developer's taste.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I'm sure other folks out there will point out other important differences between C# and VB, but these are the ones that come to mind.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=430838" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/theoy/archive/tags/Random+.NET+Platform/default.aspx">Random .NET Platform</category></item><item><title>.NET Framework SP's Available!</title><link>http://blogs.msdn.com/theoy/archive/2004/08/30/222998.aspx</link><pubDate>Tue, 31 Aug 2004 00:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:222998</guid><dc:creator>TheoY</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/theoy/comments/222998.aspx</comments><wfw:commentRss>http://blogs.msdn.com/theoy/commentrss.aspx?PostID=222998</wfw:commentRss><description>&lt;font face="Verdana" size="2"&gt; &lt;p&gt;For those who haven't gotten their hands on an Windows XPSP2 CD,&amp;nbsp;new .NET Framework SP's are now available, for versions 1.0 and 1.1 (the first version of 2.0, or "Whidbey" is still yet to be released).&lt;/p&gt; &lt;p&gt;Here are the links to Microsoft's download center, the related "Knowledge Base" links may not become active on the web for a couple hours.&amp;nbsp; When they become active, you'll be able to see a list of fixes included in these service packs.&amp;nbsp; Rest assured, these patches are a culmination of a ton of work (by&amp;nbsp;the&amp;nbsp;.NET Framework&amp;nbsp;team, and my team).&amp;nbsp; In a couple of days, they should also become available via &lt;a href="http://www.windowsupdate.com"&gt;Windows Update&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;.NET Framework Version 1.1&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A8F5654F-088E-40B2-BBDB-A83353618B38"&gt;Service Pack 1 for All OS's other than Windows Server 2003&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AE7EDEF7-2CB7-4864-8623-A1038563DF23"&gt;Service Pack 1 for Windows Server 2003&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;.NET Framework Version 1.0&lt;br /&gt;&lt;/strong&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6978D761-4A92-4106-A9BC-83E78D4ABC5B"&gt;Service Pack 3 for All OS's other than XP for Tablet PC / Media Center&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Notice there are two links for the 1.1 version: it's because the .NET Framework is installed via Windows Installer technology on most operating systems, but is incorporated as an OS component for Windows Server 2003.&lt;/p&gt; &lt;p&gt;Likewise, 1.0 .NET Framework was incorporated as part of the XP version for Tablet PC / Media Center.&amp;nbsp; So those users will actually get SP3 for the 1.0 .NET Framework by simply installing XPSP2.&lt;/p&gt; &lt;p&gt;If you're running Windows Server 2003, you should reboot after installing the 1.1 Framework SP in case some files (e.g. DLL's in the CLR and base class libraries) were in use during installation.&amp;nbsp; The patch on Windows Update will always ask for reboot for the 1.1 SP1 patch.&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=222998" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/theoy/archive/tags/Random+.NET+Platform/default.aspx">Random .NET Platform</category></item></channel></rss>