<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Should You Use Properties Internally in a Class?</title>
	<atom:link href="http://bobondevelopment.com/2007/03/02/should-you-use-properties-internally-in-a-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://bobondevelopment.com/2007/03/02/should-you-use-properties-internally-in-a-class/</link>
	<description>Musings on the craft and business of software development</description>
	<lastBuildDate>Thu, 26 Aug 2010 03:21:57 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave</title>
		<link>http://bobondevelopment.com/2007/03/02/should-you-use-properties-internally-in-a-class/comment-page-1/#comment-2117</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 23 Aug 2007 13:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://bobondevelopment.com/2007/03/02/should-you-use-properties-internally-in-a-class/#comment-2117</guid>
		<description>If a field is exposed using a property, it&#039;s best to always use that property. Why? The answer is very simple. Although properties and fields in C# look the same, they aren&#039;t the same in the CLR. Property setters are converted to a method (Set_). This method can contain additional code.  Using the field directly can cause the internal field to contain invalid data. The performance loss using the property in stead of the field is very minimal.

Unfortunately we cannot tie a field exclusively to a property.

&lt;em&gt;Bob responds: I agree with you from the viewpoint of external consumers of a class, but the question under consideration here is when to directly access fields from inside a class instance.  In this context we&#039;re not breaking encapsulation to do so, and there are good arguments for not accessing public properties from inside a class.&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>If a field is exposed using a property, it&#8217;s best to always use that property. Why? The answer is very simple. Although properties and fields in C# look the same, they aren&#8217;t the same in the CLR. Property setters are converted to a method (Set_). This method can contain additional code.  Using the field directly can cause the internal field to contain invalid data. The performance loss using the property in stead of the field is very minimal.</p>
<p>Unfortunately we cannot tie a field exclusively to a property.</p>
<p><em>Bob responds: I agree with you from the viewpoint of external consumers of a class, but the question under consideration here is when to directly access fields from inside a class instance.  In this context we&#8217;re not breaking encapsulation to do so, and there are good arguments for not accessing public properties from inside a class.</em></p>
]]></content:encoded>
	</item>
</channel>
</rss>
