<?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: C#: Public fields vs automatic properties</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Matthijs</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-30126</link>
		<dc:creator>Matthijs</dc:creator>
		<pubDate>Tue, 12 Jan 2010 12:36:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-30126</guid>
		<description>Properties can be included in an interface, fields cannot.</description>
		<content:encoded><![CDATA[<p>Properties can be included in an interface, fields cannot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: L</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-14887</link>
		<dc:creator>L</dc:creator>
		<pubDate>Sun, 19 Apr 2009 22:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-14887</guid>
		<description>Sorry - I meant &quot;public struct Rect&quot; in the previous example.</description>
		<content:encoded><![CDATA[<p>Sorry &#8211; I meant &#8220;public struct Rect&#8221; in the previous example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: L</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-14886</link>
		<dc:creator>L</dc:creator>
		<pubDate>Sun, 19 Apr 2009 22:11:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-14886</guid>
		<description>public class Rect
{
	public int Width {get;set;}
	public int Height {get;set;}
}

public class A
{
	public Rect Rect {get;set;}
}

….
A obj = new A();

// can&#039;t do this in C#
// (you could if Rect was a public data member)
a.Rect.Width = 10;</description>
		<content:encoded><![CDATA[<p>public class Rect<br />
{<br />
	public int Width {get;set;}<br />
	public int Height {get;set;}<br />
}</p>
<p>public class A<br />
{<br />
	public Rect Rect {get;set;}<br />
}</p>
<p>….<br />
A obj = new A();</p>
<p>// can&#8217;t do this in C#<br />
// (you could if Rect was a public data member)<br />
a.Rect.Width = 10;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8320</link>
		<dc:creator>Stuart</dc:creator>
		<pubDate>Fri, 06 Feb 2009 22:37:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8320</guid>
		<description>You can&#039;t use INotifyPropertyChanged on a public field.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t use INotifyPropertyChanged on a public field.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rishi</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8312</link>
		<dc:creator>Rishi</dc:creator>
		<pubDate>Fri, 06 Feb 2009 13:18:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8312</guid>
		<description>The other difference as of now is that we can&#039;t initialize automatic properties with values - the opposite is true with public fields. I believe in the .NET 4 the are gonna allow initializing automatic properties. And one of the other difference is in usage by various serialization formatters, such as the default XML serializer does not automatically serialize public fields. And lastly, a number of useful attributes are normally not allowable on fields.</description>
		<content:encoded><![CDATA[<p>The other difference as of now is that we can&#8217;t initialize automatic properties with values &#8211; the opposite is true with public fields. I believe in the .NET 4 the are gonna allow initializing automatic properties. And one of the other difference is in usage by various serialization formatters, such as the default XML serializer does not automatically serialize public fields. And lastly, a number of useful attributes are normally not allowable on fields.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Kemp</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8286</link>
		<dc:creator>Jason Kemp</dc:creator>
		<pubDate>Thu, 05 Feb 2009 13:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8286</guid>
		<description>Only properties, automatic or regular, work with things like data binding in WinForms and WPF.</description>
		<content:encoded><![CDATA[<p>Only properties, automatic or regular, work with things like data binding in WinForms and WPF.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8284</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 05 Feb 2009 10:12:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8284</guid>
		<description>You can also use

public string Bar { get; private set; }

And when you later want to implement extra logic it won&#039;t break IL code that references the property.</description>
		<content:encoded><![CDATA[<p>You can also use</p>
<p>public string Bar { get; private set; }</p>
<p>And when you later want to implement extra logic it won&#8217;t break IL code that references the property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #280</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8262</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #280</dc:creator>
		<pubDate>Thu, 05 Feb 2009 08:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8262</guid>
		<description>[...] C#: Public fields vs automatic properties - Mark Needham talks briefly about the differences between fields and automatic properties. Some good comments on this post too [...]</description>
		<content:encoded><![CDATA[<p>[...] C#: Public fields vs automatic properties &#8211; Mark Needham talks briefly about the differences between fields and automatic properties. Some good comments on this post too [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Gregory</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8156</link>
		<dc:creator>James Gregory</dc:creator>
		<pubDate>Wed, 04 Feb 2009 23:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8156</guid>
		<description>Just to clarify something, automatic properties are the same as standard properties as far as reflection is concerned; automatic properties are just syntactic sugar and produce the same IL as regular properties.</description>
		<content:encoded><![CDATA[<p>Just to clarify something, automatic properties are the same as standard properties as far as reflection is concerned; automatic properties are just syntactic sugar and produce the same IL as regular properties.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Webster</title>
		<link>http://www.markhneedham.com/blog/2009/02/04/c-public-fields-vs-automatic-properties/comment-page-1/#comment-8119</link>
		<dc:creator>James Webster</dc:creator>
		<pubDate>Wed, 04 Feb 2009 20:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=899#comment-8119</guid>
		<description>Field and properties are also treated differently at the level of reflection; there isn&#039;t one method on Type that will return both fields AND properties (other than GetMemberInfo I expect, which will return events and methods as well).

So going down the the automatic property route may deal with reflection difficulties (eg. NHibernate or your own serialisation framework may only handle properties perhaps?)</description>
		<content:encoded><![CDATA[<p>Field and properties are also treated differently at the level of reflection; there isn&#8217;t one method on Type that will return both fields AND properties (other than GetMemberInfo I expect, which will return events and methods as well).</p>
<p>So going down the the automatic property route may deal with reflection difficulties (eg. NHibernate or your own serialisation framework may only handle properties perhaps?)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

