<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" 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:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Coffeehouse - C# Extension Properties?</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Coffeehouse - C# Extension Properties?</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Sun, 26 May 2013 04:20:17 GMT</pubDate>
	<lastBuildDate>Sun, 26 May 2013 04:20:17 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>42</c9:totalResults>
	<c9:pageCount>-42</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>In C# 3 you can create an extension method like this:<br>
<font face="Courier New"><br>
public static class Extensions {<br>
&nbsp;&nbsp;&nbsp; public static string ToCamelCase(<b>this</b> string s) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // perform action<br>
&nbsp;&nbsp;&nbsp; }<br>
}</font><br>
<br>
Well what about properties? They could act as an indexer would, by using brackets around parameters:<br>
<br>
<font face="Courier New">public static class Extensions {<br>
&nbsp;&nbsp;&nbsp; public static object Cell[<b>this</b> DataTable t, int row, int column] {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return t.Rows[row][column]; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="Courier New">set { t.Rows[row][column] = value; }</font><br>
<font face="Courier New"></font><font face="Courier New">&nbsp;&nbsp;&nbsp; }<br>
}<br>
// ...<br>
// usage<br>
dataTable.Cell[0, 2] = &quot;Hello World&quot;;<br>
<br>
</font>That example is simple, but I think it could be a powerful concept. Take, for example, Extended Properties in WPF, which can't be added to the class. Extension Properties would allow a simpler syntax. There are also areas in the .NET Framework where
 a Property would be better suited but a &quot;GetXXX(type param)&quot; method was used because Parameterized Properties don't exist.<br>
<br>
I dunno, it could end up cluttering the language. What do you think?<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/257556#257556</link>
		<pubDate>Wed, 12 Sep 2007 03:58:32 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/257556#257556</guid>
		<dc:creator>ktr</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ktr/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>Yeah, I was hoping for extension properties too:<br>
<br>
<font face="Courier New"><font color="#0000ff">public static</font> <font color="#008000">
TimeSpan</font> Minutes[<font color="#0000ff">this</font> <font color="#0000ff">int</font> i]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> {&nbsp;<font color="#0000ff">return new</font> <font color="#008000">
TimeSpan</font>(0, i, 0); }<br>
}<br>
<br>
<font color="#0000ff">public static</font> <font color="#008000">DateTime</font> Ago[<font color="#0000ff">this</font>
<font color="#008000">TimeSpan</font> ts]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> { <font color="#0000ff">return</font> <font color="#008000">
DateTime</font>.Now.Subtract(ts); }<br>
}</font><br>
<br>
So then I could do:<br>
<br>
<font face="Courier New"><font color="#008000">DateTime</font> d = 20.Minutes.Ago;</font><br>
<br>
No ugly parentheses!</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9172046763fa4b66bd799deb0015bf16#9172046763fa4b66bd799deb0015bf16</link>
		<pubDate>Wed, 12 Sep 2007 05:14:52 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9172046763fa4b66bd799deb0015bf16#9172046763fa4b66bd799deb0015bf16</guid>
		<dc:creator>Matt Hamilton</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/mabster/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>Exactly. It would be great to have these to get/set WPF attached properties. For Example, instead of writing this:<br>
<br>
<font face="Courier New">DockPanel.SetDock(btn1, Dock.Left);<br>
</font><font face="Courier New">DockPanel.SetDock(btn2, Dock.Left);<br>
</font><font face="Courier New">DockPanel.SetDock(btn3, Dock.Left);</font><br>
<br>
You would write this instead:<br>
<br>
<font face="Courier New">btn1.Dock = btn2.Dock = btn3.Dock = Dock.Left;<br>
</font><br>
Much cooler <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-11.gif' alt='Cool' /><br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/75d2795ce1c54f0681999deb0015bf40#75d2795ce1c54f0681999deb0015bf40</link>
		<pubDate>Wed, 12 Sep 2007 15:20:46 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/75d2795ce1c54f0681999deb0015bf40#75d2795ce1c54f0681999deb0015bf40</guid>
		<dc:creator>ktr</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ktr/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">mabster wrote:</div>
<div class="quoteBody">&#65279;Yeah, I was hoping for extension properties too:<br>
<br>
<font face="Courier New"><font color="#0000ff">public static</font> <font color="#008000">
TimeSpan</font> Minutes[<font color="#0000ff">this</font> <font color="#0000ff">int</font> i]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> {&nbsp;<font color="#0000ff">return new</font> <font color="#008000">
TimeSpan</font>(0, i, 0); }<br>
}<br>
<br>
<font color="#0000ff">public static</font> <font color="#008000">DateTime</font> Ago[<font color="#0000ff">this</font>
<font color="#008000">TimeSpan</font> ts]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> { <font color="#0000ff">return</font> <font color="#008000">
DateTime</font>.Now.Subtract(ts); }<br>
}</font><br>
<br>
So then I could do:<br>
<br>
<font face="Courier New"><font color="#008000">DateTime</font> d = 20.Minutes.Ago;</font><br>
<br>
No ugly parentheses!</div>
</blockquote>
<br>
<br>
Sweet. That looks Ruby'ish (not to be mistaken by Rubish). Not that I like Ruby. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b27075409dd7409696d09deb0015bf6d#b27075409dd7409696d09deb0015bf6d</link>
		<pubDate>Wed, 12 Sep 2007 16:23:46 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b27075409dd7409696d09deb0015bf6d#b27075409dd7409696d09deb0015bf6d</guid>
		<dc:creator>Bent Rasmussen</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/esoteric/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">mabster wrote:</div>
<div class="quoteBody">&#65279;Yeah, I was hoping for extension properties too:<br>
<br>
<font face="Courier New"><font color="#0000ff">public static</font> <font color="#008000">
TimeSpan</font> Minutes[<font color="#0000ff">this</font> <font color="#0000ff">int</font> i]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> {&nbsp;<font color="#0000ff">return new</font> <font color="#008000">
TimeSpan</font>(0, i, 0); }<br>
}<br>
<br>
<font color="#0000ff">public static</font> <font color="#008000">DateTime</font> Ago[<font color="#0000ff">this</font>
<font color="#008000">TimeSpan</font> ts]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> { <font color="#0000ff">return</font> <font color="#008000">
DateTime</font>.Now.Subtract(ts); }<br>
}</font><br>
<br>
So then I could do:<br>
<br>
<font face="Courier New"><font color="#008000">DateTime</font> d = 20.Minutes.Ago;</font><br>
<br>
No ugly parentheses!</div>
</blockquote>
yeah but its confusing and is too close&nbsp;to an&nbsp;an indexer</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/fb12cc1917f846a6b2709deb0015bf9a#fb12cc1917f846a6b2709deb0015bf9a</link>
		<pubDate>Wed, 12 Sep 2007 22:36:39 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/fb12cc1917f846a6b2709deb0015bf9a#fb12cc1917f846a6b2709deb0015bf9a</guid>
		<dc:creator>Ion Todirel</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Ion Todirel/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>How is 20.Minutes.Ago more confusing than DateTime.Now.Subtract(new TimeSpan(0, 20, 0))?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d9b8a9fcbbe24c71ba809deb0015bfc4#d9b8a9fcbbe24c71ba809deb0015bfc4</link>
		<pubDate>Thu, 13 Sep 2007 05:30:19 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d9b8a9fcbbe24c71ba809deb0015bfc4#d9b8a9fcbbe24c71ba809deb0015bfc4</guid>
		<dc:creator>Tommy Carlier</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/TommyCarlier/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">TommyCarlier wrote:</div>
<div class="quoteBody">How is 20.Minutes.Ago more confusing than DateTime.Now.Subtract(new TimeSpan(0, 20, 0))?</div>
</blockquote>
<br>
<br>
lol. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> thanks for that.<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/e8108808a4b04514a9e89deb0015c00b#e8108808a4b04514a9e89deb0015c00b</link>
		<pubDate>Thu, 13 Sep 2007 09:56:06 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/e8108808a4b04514a9e89deb0015c00b#e8108808a4b04514a9e89deb0015c00b</guid>
		<dc:creator>dcuccia</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/dcuccia/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">TommyCarlier said:</div><div class="quoteText">How is 20.Minutes.Ago more confusing than DateTime.Now.Subtract(new TimeSpan(0, 20, 0))?</div></blockquote>It's not.&nbsp; However, there are side effects.&nbsp; Having the ability to write DateTime.Now.Ago is definitely confusing.&nbsp; The Ago property
 would show up on all DateTimes (provided the using statement is there).&nbsp; The idea is good, though.&nbsp; Having an int extension property named MinutesAgo seems better.<br>
<br>
I too would have liked to see extension properties.&nbsp; We have custom properties that we read from the DB and are generating them onto classes.&nbsp; We are forced to use the ugly GetPropertyname() syntax.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/3ba5f39128194e7da6bd9deb0015c056#3ba5f39128194e7da6bd9deb0015c056</link>
		<pubDate>Mon, 25 Aug 2008 02:44:38 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/3ba5f39128194e7da6bd9deb0015c056#3ba5f39128194e7da6bd9deb0015c056</guid>
		<dc:creator>GaryC</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/GaryC/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">GaryC said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">TommyCarlier said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
It's not.&nbsp; However, there are side effects.&nbsp; Having the ability to write DateTime.Now.Ago is definitely confusing.&nbsp; The Ago property would show up on all DateTimes (provided the using statement is there).&nbsp; The idea is good, though.&nbsp; Having an int extension
 property named MinutesAgo seems better.<br>
<br>
I too would have liked to see extension properties.&nbsp; We have custom properties that we read from the DB and are generating them onto classes.&nbsp; We are forced to use the ugly GetPropertyname() syntax.</div></blockquote>
<p>Holy cow... I wanted to reply but this thread is over a year old... and now I did it <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-6.gif' alt='Sad' /></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b2788444a3674ff480c09deb0015c082#b2788444a3674ff480c09deb0015c082</link>
		<pubDate>Mon, 25 Aug 2008 02:54:51 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b2788444a3674ff480c09deb0015c082#b2788444a3674ff480c09deb0015c082</guid>
		<dc:creator>Christian Liensberger</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/littleguru/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">GaryC said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">TommyCarlier said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
It's not.&nbsp; However, there are side effects.&nbsp; Having the ability to write DateTime.Now.Ago is definitely confusing.&nbsp; The Ago property would show up on all DateTimes (provided the using statement is there).&nbsp; The idea is good, though.&nbsp; Having an int extension
 property named MinutesAgo seems better.<br>
<br>
I too would have liked to see extension properties.&nbsp; We have custom properties that we read from the DB and are generating them onto classes.&nbsp; We are forced to use the ugly GetPropertyname() syntax.</div></blockquote>Actually, as he wrote it the &quot;Ago&quot; property would show
 up on TimeSpan, not on DateTime, which makes a lot more sense. So you wouldn't actually be able to do DateTime.Now.Ago.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0b7b521eeefc46f8b7579deb0015c0ae#0b7b521eeefc46f8b7579deb0015c0ae</link>
		<pubDate>Mon, 25 Aug 2008 03:00:57 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0b7b521eeefc46f8b7579deb0015c0ae#0b7b521eeefc46f8b7579deb0015c0ae</guid>
		<dc:creator>Sven Groot</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Sven Groot/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">TommyCarlier said:</div><div class="quoteText">How is 20.Minutes.Ago more confusing than DateTime.Now.Subtract(new TimeSpan(0, 20, 0))?</div></blockquote>I meant the extension property declaration will be confusing and very close in definition to a indexer<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/f1c2d3ff600d4d35b4de9deb0015c0d8#f1c2d3ff600d4d35b4de9deb0015c0d8</link>
		<pubDate>Mon, 25 Aug 2008 10:41:30 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/f1c2d3ff600d4d35b4de9deb0015c0d8#f1c2d3ff600d4d35b4de9deb0015c0d8</guid>
		<dc:creator>Ion Todirel</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Ion Todirel/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Ion Todirel said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">TommyCarlier said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
I meant the extension property declaration will be confusing and very close in definition to a indexer<br>
</div></blockquote>The way I read it, the reason extension properties didn't make it in was because they couldn't reach consensus about a good syntax for declaring them.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/246a99bf6554478988499deb0015c103#246a99bf6554478988499deb0015c103</link>
		<pubDate>Mon, 25 Aug 2008 10:48:51 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/246a99bf6554478988499deb0015c103#246a99bf6554478988499deb0015c103</guid>
		<dc:creator>Sven Groot</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Sven Groot/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Sven Groot said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Ion Todirel said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
The way I read it, the reason extension properties didn't make it in was because they couldn't reach consensus about a good syntax for declaring them.</div></blockquote>yep, that's what I wanted to say...<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0b0b6d7acc2d4172bf4f9deb0015c18d#0b0b6d7acc2d4172bf4f9deb0015c18d</link>
		<pubDate>Mon, 25 Aug 2008 10:59:59 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0b0b6d7acc2d4172bf4f9deb0015c18d#0b0b6d7acc2d4172bf4f9deb0015c18d</guid>
		<dc:creator>Ion Todirel</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Ion Todirel/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">mabster said:</div><div class="quoteText">Yeah, I was hoping for extension properties too:<br>
<br>
<font face="Courier New"><font color="#0000ff">public static</font> <font color="#008000">
TimeSpan</font> Minutes[<font color="#0000ff">this</font> <font color="#0000ff">int</font> i]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> {&nbsp;<font color="#0000ff">return new</font> <font color="#008000">
TimeSpan</font>(0, i, 0); }<br>
}<br>
<br>
<font color="#0000ff">public static</font> <font color="#008000">DateTime</font> Ago[<font color="#0000ff">this</font>
<font color="#008000">TimeSpan</font> ts]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> { <font color="#0000ff">return</font> <font color="#008000">
DateTime</font>.Now.Subtract(ts); }<br>
}</font><br>
<br>
So then I could do:<br>
<br>
<font face="Courier New"><font color="#008000">DateTime</font> d = 20.Minutes.Ago;</font><br>
<br>
No ugly parentheses!</div></blockquote>Hah.&nbsp; Reminds me of a query I saw recently.&nbsp; At my new job, we communicate alot with an ancient DB2 system; someone posted a query like:<br>
<br>
Select * from abc.defg<br>
where dt = ? - 180 days<br>
<br>
I was like, what? Awesome.<br>
<br>
Then someone showed me that TOP 10 is now FETCH FIRST 10 ROWS ONLY.&nbsp; And the awe was gone.<br>
<br>
Don't get me started.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/aed905a9df5949af89809deb0015c1ba#aed905a9df5949af89809deb0015c1ba</link>
		<pubDate>Wed, 27 Aug 2008 00:28:29 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/aed905a9df5949af89809deb0015c1ba#aed905a9df5949af89809deb0015c1ba</guid>
		<dc:creator>tsilb</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/SlackmasterK/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>I was wondering about this feature as well. Could the syntax look something like this:<br>
<br>
public static class Extensions {<br>
&nbsp;&nbsp;&nbsp; public static object Cell{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get(this DataTable t, int row, int column)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return t.Rows[row][column]; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set(this DataTable t, int row, int column)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ t.Rows[row][column] = value; }<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>
// usage<br>
dataTable.Cell[0, 2] = &quot;Hello World&quot;;<br>
<br>
The usage would be the same, but the compiler would just have to translate this new syntax and it differs from indexing syntax.</p>
<p>public static TimeSpan Minutes<br>
{<br>
&nbsp;&nbsp; get(this int i)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;return new TimeSpan(0, i, 0); }<br>
}<br>
<br>
public static DateTime Ago<br>
{<br>
&nbsp;&nbsp; get(this TimeSpan ts)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;{ return DateTime.Now.Subtract(ts); }<br>
}<br>
<br>
They still look like properties.<br>
<br>
Andres<br>
<br>
</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/fecab56185b34db7b5399deb0015c206#fecab56185b34db7b5399deb0015c206</link>
		<pubDate>Fri, 30 Jan 2009 16:56:13 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/fecab56185b34db7b5399deb0015c206#fecab56185b34db7b5399deb0015c206</guid>
		<dc:creator>Andres Olivares</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/AndresOlivares/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>I'm probably in the minority here, but I think the whole extension methods concept is confusing.&nbsp; If you want to add a method to a class, then subclass it.&nbsp; That's why inheritance exists, and it makes a lot more sense to me when I see MyTimeSpan.Ago rather
 than TimeSpan.Ago, because I might go searching the MSDN for documentation on TimeSpan.Ago only to find it doesn't exist.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/3a3ec9e89e14467889549deb0015c250#3a3ec9e89e14467889549deb0015c250</link>
		<pubDate>Fri, 30 Jan 2009 17:55:55 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/3a3ec9e89e14467889549deb0015c250#3a3ec9e89e14467889549deb0015c250</guid>
		<dc:creator>Scott</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/spivonious/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">spivonious said:</div><div class="quoteText">I'm probably in the minority here, but I think the whole extension methods concept is confusing.&nbsp; If you want to add a method to a class, then subclass it.&nbsp; That's why inheritance exists, and it makes a lot more sense to me when
 I see MyTimeSpan.Ago rather than TimeSpan.Ago, because I might go searching the MSDN for documentation on TimeSpan.Ago only to find it doesn't exist.</div></blockquote>&gt; &nbsp;If you want to add a method to a class, then subclass it.<br>
<br>
What if the class you want to add a method to is sealed or worse, is a struct, preventing you from doing just that? Not unlike DateTime, TimeSpan or String?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/92561d697a2e49638e9b9deb0015c27d#92561d697a2e49638e9b9deb0015c27d</link>
		<pubDate>Fri, 30 Jan 2009 18:14:53 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/92561d697a2e49638e9b9deb0015c27d#92561d697a2e49638e9b9deb0015c27d</guid>
		<dc:creator>dahat</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/dahat/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">dahat said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">spivonious said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
&gt; &nbsp;If you want to add a method to a class, then subclass it.<br>
<br>
What if the class you want to add a method to is sealed or worse, is a struct, preventing you from doing just that? Not unlike DateTime, TimeSpan or String?</div></blockquote>Well, without the extension method language feature, you'd have to use the
<a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. If you only want to add a single method, that's potentially an awful lot of work, which is why I like extensions.<br>
<br>
For me the real strength of extension methods is in adding type-inferenced extension methods to interface, so that classes inheriting that interface automatically get interface-related functionality for free (we discussed this a while ago over on
<a href="http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/">
this thread</a>).<br>
<br>
<br>
Herbie<br>
<br>
<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/55e9a50f7b16409a94f19deb0015c2aa#55e9a50f7b16409a94f19deb0015c2aa</link>
		<pubDate>Fri, 30 Jan 2009 18:46:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/55e9a50f7b16409a94f19deb0015c2aa#55e9a50f7b16409a94f19deb0015c2aa</guid>
		<dc:creator>Herbie Smith</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Dr Herbie/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dr Herbie said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">dahat said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
Well, without the extension method language feature, you'd have to use the <a href="http://en.wikipedia.org/wiki/Decorator_pattern">
decorator pattern</a>. If you only want to add a single method, that's potentially an awful lot of work, which is why I like extensions.<br>
<br>
For me the real strength of extension methods is in adding type-inferenced extension methods to interface, so that classes inheriting that interface automatically get interface-related functionality for free (we discussed this a while ago over on
<a href="http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/">
this thread</a>).<br>
<br>
<br>
Herbie<br>
<br>
<br>
</div></blockquote>
<p>In regards to extension methods being confusing, I agree in that extension methods are extraordinarily powerful and thus have dramatic potential for misuse.&nbsp; However there are a few cases such as adding context specific methods to base objects like object
 or string or adding methods to a system interface like IList where they are the best way to perform the move.</p>
<p>&nbsp;</p>
<p>That being said it is sad that extension properties, which seem to me to be no more or less powerful or appropriate than extension methods were not included simply because an agreement on the declaration syntax could not be reached.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/1c1ceeb36fe64e5d8fdc9deb0015c2f7#1c1ceeb36fe64e5d8fdc9deb0015c2f7</link>
		<pubDate>Mon, 24 Aug 2009 20:47:23 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/1c1ceeb36fe64e5d8fdc9deb0015c2f7#1c1ceeb36fe64e5d8fdc9deb0015c2f7</guid>
		<dc:creator>Jake</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/frindly1000/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Dr Herbie said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">dahat said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
Well, without the extension method language feature, you'd have to use the <a href="http://en.wikipedia.org/wiki/Decorator_pattern">
decorator pattern</a>. If you only want to add a single method, that's potentially an awful lot of work, which is why I like extensions.<br>
<br>
For me the real strength of extension methods is in adding type-inferenced extension methods to interface, so that classes inheriting that interface automatically get interface-related functionality for free (we discussed this a while ago over on
<a href="http://channel9.msdn.com/forums/TechOff/426863-Interface--Extension-Methods-any-improvement-on-abstract-classes/">
this thread</a>).<br>
<br>
<br>
Herbie<br>
<br>
<br>
</div></blockquote>
<p>You cannot subclass a sealed class or a struct&nbsp;to implement the decorator pattern.</p>
<p>EDIT:&nbsp;Oops, thread necromancy.&nbsp; grr, frindly1000!</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/cd7653661fdd45d2af999deb0015c341#cd7653661fdd45d2af999deb0015c341</link>
		<pubDate>Mon, 24 Aug 2009 21:15:26 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/cd7653661fdd45d2af999deb0015c341#cd7653661fdd45d2af999deb0015c341</guid>
		<dc:creator>Joe Chung</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/joechung/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">frindly1000 said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Dr Herbie said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>In regards to extension methods being confusing, I agree in that extension methods are extraordinarily powerful and thus have dramatic potential for misuse.&nbsp; However there are a few cases such as adding context specific methods to base objects like object
 or string or adding methods to a system interface like IList where they are the best way to perform the move.</p>
<p>&nbsp;</p>
<p>That being said it is sad that extension properties, which seem to me to be no more or less powerful or appropriate than extension methods were not included simply because an agreement on the declaration syntax could not be reached.</p>
</div></blockquote>
<p>Still, using a pair of empty ellipses, you can still achieve the same effect, i.e. (for gets, not for sets)</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">20.Minutes().Ago()</pre>
<p></p>
<p>&nbsp;</p>
<p>I <a href="http://www.scala-lang.org/node/118">believe </a>in Scala you can use any method using infix notation so you might be able to express something like</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: text">20 minutes ago</pre>
<p></p>
<p>&nbsp;</p>
<p>I'm experimenting with using extension methods to achieve null-safe &quot;object-oriented&quot; expressions</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">int? v = element.Value().Eval&lt;int&gt;();</pre>
<p></p>
<p>&nbsp;</p>
<p>Value(), as an extension method over XElement, and Eval as an extension method over object, are both null-safe. If element is null, then the whole expression evaluates to null; if element.Value() is null, then the whole expression evaluates to null; if element.Value().Eval&lt;int&gt;()
 is not possible (format error or unsupported conversion), then the whole expression evaluates to null.&nbsp;</p>
<p>&nbsp;</p>
<p>This property, that one can model null-safety with extension methods is absolutely adorable.</p>
<p>&nbsp;</p>
<p>I think the C# field/method/property system is a bit non-uniform now, but it's still very useable and powerful.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/db6e2e7e365a4feab21e9deb0015c378#db6e2e7e365a4feab21e9deb0015c378</link>
		<pubDate>Mon, 24 Aug 2009 22:04:19 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/db6e2e7e365a4feab21e9deb0015c378#db6e2e7e365a4feab21e9deb0015c378</guid>
		<dc:creator>Bent Rasmussen</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/exoteric/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">exoteric said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">frindly1000 said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Still, using a pair of empty ellipses, you can still achieve the same effect, i.e. (for gets, not for sets)</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">20.Minutes().Ago()</pre>
<p></p>
<p>&nbsp;</p>
<p>I <a href="http://www.scala-lang.org/node/118">believe </a>in Scala you can use any method using infix notation so you might be able to express something like</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: text">20 minutes ago</pre>
<p></p>
<p>&nbsp;</p>
<p>I'm experimenting with using extension methods to achieve null-safe &quot;object-oriented&quot; expressions</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">int? v = element.Value().Eval&lt;int&gt;();</pre>
<p></p>
<p>&nbsp;</p>
<p>Value(), as an extension method over XElement, and Eval as an extension method over object, are both null-safe. If element is null, then the whole expression evaluates to null; if element.Value() is null, then the whole expression evaluates to null; if element.Value().Eval&lt;int&gt;()
 is not possible (format error or unsupported conversion), then the whole expression evaluates to null.&nbsp;</p>
<p>&nbsp;</p>
<p>This property, that one can model null-safety with extension methods is absolutely adorable.</p>
<p>&nbsp;</p>
<p>I think the C# field/method/property system is a bit non-uniform now, but it's still very useable and powerful.</p>
</div></blockquote>
<p>True, but you can't use that in something like databinding (in WPF or Silverlight at least). Sometimes you just need a property.</p>
<p>Having extension properties would be extremely powerful in a scenario where you use something like LinqToSql in a service, use partial classes there to make properties available in the DataContract and then use some extension properties to format some properties
 for databinding.</p>
<p>I know I could do the latter with a valueconverter but I find that more troublesome then it needs to be.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b1c02eb0f6ac4c1ba6839deb0015c3c9#b1c02eb0f6ac4c1ba6839deb0015c3c9</link>
		<pubDate>Wed, 23 Sep 2009 07:44:31 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b1c02eb0f6ac4c1ba6839deb0015c3c9#b1c02eb0f6ac4c1ba6839deb0015c3c9</guid>
		<dc:creator>Jonathan van de Veen</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/mrjvdveen/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>Coding WPF classes in C# sometimes feels like coding COM classes in C&#43;&#43;: you have to explicitly provide plumbing that obscures the high-level abstractions. &nbsp;XAML is nicer, but it's both limited in capability and saddled with clunky XML syntax. &nbsp;This is my
 biggest problem with WPF, an API that in the abstract is very nice, I just wish there were a better view into it ... like JavaFX Script. &nbsp; <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-4.gif' alt='Tongue Out' />
</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d9d535b81cf2446aaa179deb0015c413#d9d535b81cf2446aaa179deb0015c413</link>
		<pubDate>Wed, 23 Sep 2009 17:33:56 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d9d535b81cf2446aaa179deb0015c413#d9d535b81cf2446aaa179deb0015c413</guid>
		<dc:creator>contextfree</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/contextfree/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">contextfree said:</div><div class="quoteText">
<p>Coding WPF classes in C# sometimes feels like coding COM classes in C&#43;&#43;: you have to explicitly provide plumbing that obscures the high-level abstractions. &nbsp;XAML is nicer, but it's both limited in capability and saddled with clunky XML syntax. &nbsp;This is my
 biggest problem with WPF, an API that in the abstract is very nice, I just wish there were a better view into it ... like JavaFX Script. &nbsp;
<img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-4.gif" alt="Tongue Out">
</p>
</div></blockquote>
<p>Blend doesnt suit your needs?</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/189b275b4858432e9d239deb0015c43f#189b275b4858432e9d239deb0015c43f</link>
		<pubDate>Thu, 24 Sep 2009 08:02:40 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/189b275b4858432e9d239deb0015c43f#189b275b4858432e9d239deb0015c43f</guid>
		<dc:creator>Maddus Mattus</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Maddus Mattus/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Maddus Mattus said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">contextfree said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Blend doesnt suit your needs?</p>
</div></blockquote>
<p>I haven't used it much, but it's a visual designer, right? &nbsp;There's more to WPF than visual design. &nbsp;I'm thinking of setting up dependency properties, etc.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/c29bf54e96414534972f9deb0015c469#c29bf54e96414534972f9deb0015c469</link>
		<pubDate>Thu, 24 Sep 2009 17:34:12 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/c29bf54e96414534972f9deb0015c469#c29bf54e96414534972f9deb0015c469</guid>
		<dc:creator>contextfree</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/contextfree/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">mabster said:</div><div class="quoteText">Yeah, I was hoping for extension properties too:<br>
<br>
<font face="Courier New"><font color="#0000ff">public static</font> <font color="#008000">
TimeSpan</font> Minutes[<font color="#0000ff">this</font> <font color="#0000ff">int</font> i]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> {&nbsp;<font color="#0000ff">return new</font> <font color="#008000">
TimeSpan</font>(0, i, 0); }<br>
}<br>
<br>
<font color="#0000ff">public static</font> <font color="#008000">DateTime</font> Ago[<font color="#0000ff">this</font>
<font color="#008000">TimeSpan</font> ts]<br>
{<br>
&nbsp;&nbsp; <font color="#0000ff">get</font> { <font color="#0000ff">return</font> <font color="#008000">
DateTime</font>.Now.Subtract(ts); }<br>
}</font><br>
<br>
So then I could do:<br>
<br>
<font face="Courier New"><font color="#008000">DateTime</font> d = 20.Minutes.Ago;</font><br>
<br>
No ugly parentheses!</div></blockquote>
<p>Or you could use VB.NET, where you don't need parentesis after methods <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' /></p>
<p>Me to would like extension properties in .net c#; more lika an&nbsp;Aspect oriented aproach</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/513214649481409ea9229deb0015c4b4#513214649481409ea9229deb0015c4b4</link>
		<pubDate>Wed, 07 Oct 2009 08:44:28 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/513214649481409ea9229deb0015c4b4#513214649481409ea9229deb0015c4b4</guid>
		<dc:creator>Jonwib</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Jonwib/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Jonwib said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">mabster said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Or you could use VB.NET, where you don't need parentesis after methods <img src="http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif" alt="Wink"></p>
<p>Me to would like extension properties in .net c#; more lika an&nbsp;Aspect oriented aproach</p>
</div></blockquote>
<p>I did something like this to copy Jquery.data function</p>
<p>&nbsp;</p>
<p><em>public static class extends{<br>
&nbsp;&nbsp;public static Dictionary&gt; v = new Dictionary&gt;();<br>
&nbsp;&nbsp;public static object data(this object o, object key,object val = null)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;if (!v.ContainsKey(o))<br>
&nbsp;&nbsp;&nbsp;v[o] = new Dictionary();<br>
&nbsp;&nbsp;&nbsp;if(val!=null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;return v[o][key];<br>
&nbsp;&nbsp;&nbsp;v[o][key] = val;<br>
&nbsp;&nbsp;&nbsp;return val;<br>
&nbsp;&nbsp;}<br>
}</em></p>
<p><em><span><br>
</span></em></p>
<p>It won't distinguish between equal simple types, but for complex it works well.</p>
<p>&nbsp;</p>
<p>With this you can call any object's data method</p>
<p>&nbsp;</p>
<p>F = new Form();</p>
<p>F.data(&quot;language&quot;,&quot;EN&quot;);</p>
<p>&nbsp;</p>
<p>and inside F you could call</p>
<p>&nbsp;</p>
<p>this.data(&quot;language&quot;) and it would return &quot;EN&quot;</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/bbc8b836e60f44f1bef79deb0015c4ff#bbc8b836e60f44f1bef79deb0015c4ff</link>
		<pubDate>Thu, 22 Jul 2010 08:32:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/bbc8b836e60f44f1bef79deb0015c4ff#bbc8b836e60f44f1bef79deb0015c4ff</guid>
		<dc:creator>ExceptionDuck</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ExceptionDuck/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">ExceptionDuck said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Jonwib said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>I did something like this to copy Jquery.data function</p>
<p>&nbsp;</p>
<p><em>public static class extends{<br>
&nbsp;&nbsp;public static Dictionary&gt; v = new Dictionary&gt;();<br>
&nbsp;&nbsp;public static object data(this object o, object key,object val = null)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;if (!v.ContainsKey(o))<br>
&nbsp;&nbsp;&nbsp;v[o] = new Dictionary();<br>
&nbsp;&nbsp;&nbsp;if(val!=null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;return v[o][key];<br>
&nbsp;&nbsp;&nbsp;v[o][key] = val;<br>
&nbsp;&nbsp;&nbsp;return val;<br>
&nbsp;&nbsp;}<br>
}</em></p>
<p><em><span><br>
</span></em></p>
<p>It won't distinguish between equal simple types, but for complex it works well.</p>
<p>&nbsp;</p>
<p>With this you can call any object's data method</p>
<p>&nbsp;</p>
<p>F = new Form();</p>
<p>F.data(&quot;language&quot;,&quot;EN&quot;);</p>
<p>&nbsp;</p>
<p>and inside F you could call</p>
<p>&nbsp;</p>
<p>this.data(&quot;language&quot;) and it would return &quot;EN&quot;</p>
</div></blockquote>
<p>Wow, thread Necromancy!</p>
<p>&nbsp;</p>
<p>Also, use F# you can extend everything <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/8cc306407ac64ee5b8c49deb0015c52d#8cc306407ac64ee5b8c49deb0015c52d</link>
		<pubDate>Fri, 23 Jul 2010 14:57:52 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/8cc306407ac64ee5b8c49deb0015c52d#8cc306407ac64ee5b8c49deb0015c52d</guid>
		<dc:creator>Massif</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Massif/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><h4><strong><a href="http://www.fsguy.com/2010-09-09_property-extensions-in-csharp-5-0">Property extensions in C# 5.0</a></strong></h4>
<p></p>
<pre class="brush: csharp">// A product type in this sample has a property Name of type String
var product = new Product();

// This will print &quot;Product.Name.IsDirty: False&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Now let's try to update product's Name property
product.Name = &quot;C# 4.0 in a Nutshell&quot;;

// And now this will print &quot;Product.Name.IsDirty: True&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Then when you try to save this product in database, it will be easier for
// Store Repository detect which fields must be saved and which can be skipped
storeRepository.Add(product);
storeRepository.SubmitChanges();</pre>
<p></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/993cfb62e07b4af7a0369dec00a8e853#993cfb62e07b4af7a0369dec00a8e853</link>
		<pubDate>Thu, 09 Sep 2010 02:34:32 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/993cfb62e07b4af7a0369dec00a8e853#993cfb62e07b4af7a0369dec00a8e853</guid>
		<dc:creator>Koistya `Navin</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/koistya/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">koistya said:</div><div class="quoteText">
<h4><strong><a href="http://www.fsguy.com/2010-09-09_property-extensions-in-csharp-5-0">Property extensions in C# 5.0</a></strong></h4>
<p></p>
<pre class="brush: csharp">// A product type in this sample has a property Name of type String
var product = new Product();

// This will print &quot;Product.Name.IsDirty: False&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Now let's try to update product's Name property
product.Name = &quot;C# 4.0 in a Nutshell&quot;;

// And now this will print &quot;Product.Name.IsDirty: True&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Then when you try to save this product in database, it will be easier for
// Store Repository detect which fields must be saved and which can be skipped
storeRepository.Add(product);
storeRepository.SubmitChanges();</pre>
<p></p>
</div></blockquote>
<p>That's not the same thing, that's &quot;properties for properties&quot; which is just <em>
messed up</em> in my opinion.</p>
<p>&nbsp;</p>
<p>I'm perfectly happy with C# 2.0, I only rarely use C# 3.0 (and when I do, it's for Linq).</p>
<p>&nbsp;</p>
<p>Wait a sec... this isn't an official blog posting, you're not an employee or someone involved in the language design process. Is this just an example you're proposing or what?</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9369ca5a13934ccf83f19dec00a8e87f#9369ca5a13934ccf83f19dec00a8e87f</link>
		<pubDate>Thu, 09 Sep 2010 02:54:37 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9369ca5a13934ccf83f19dec00a8e87f#9369ca5a13934ccf83f19dec00a8e87f</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">koistya said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>That's not the same thing, that's &quot;properties for properties&quot; which is just <em>
messed up</em> in my opinion.</p>
<p>&nbsp;</p>
<p>I'm perfectly happy with C# 2.0, I only rarely use C# 3.0 (and when I do, it's for Linq).</p>
<p>&nbsp;</p>
<p>Wait a sec... this isn't an official blog posting, you're not an employee or someone involved in the language design process. Is this just an example you're proposing or what?</p>
</div></blockquote>
<p><span id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_UsernameLabel"><a id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_UsernameLink" href="http://channel9.msdn.com/Niners/W3bbo/">W3bbo</a>, I am trying to make people think and be creative&nbsp;imagining
 the feature with me <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' /></span></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/89e09ade29f94d74b6009dec00a8e8ae#89e09ade29f94d74b6009dec00a8e8ae</link>
		<pubDate>Thu, 09 Sep 2010 03:26:46 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/89e09ade29f94d74b6009dec00a8e8ae#89e09ade29f94d74b6009dec00a8e8ae</guid>
		<dc:creator>Koistya `Navin</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/koistya/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">koistya said:</div><div class="quoteText">
<h4><strong><a href="http://www.fsguy.com/2010-09-09_property-extensions-in-csharp-5-0">Property extensions in C# 5.0</a></strong></h4>
<p></p>
<pre class="brush: csharp">// A product type in this sample has a property Name of type String
var product = new Product();

// This will print &quot;Product.Name.IsDirty: False&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Now let's try to update product's Name property
product.Name = &quot;C# 4.0 in a Nutshell&quot;;

// And now this will print &quot;Product.Name.IsDirty: True&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Then when you try to save this product in database, it will be easier for
// Store Repository detect which fields must be saved and which can be skipped
storeRepository.Add(product);
storeRepository.SubmitChanges();</pre>
<p></p>
</div></blockquote>
<p>&gt; product.Name = <span class="string">&quot;T-Short&quot;</span>;<br>
&gt; product.Name.IsDirty</p>
<p>Actually there's nothing prevent you to use &quot;product.Name_IsDirty&quot;. That kind of extension makes so little in readability improvement so probably just not worth the effort to change.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b54e3d4495844a12b2e09dec00a8e8da#b54e3d4495844a12b2e09dec00a8e8da</link>
		<pubDate>Thu, 09 Sep 2010 03:43:56 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/b54e3d4495844a12b2e09dec00a8e8da#b54e3d4495844a12b2e09dec00a8e8da</guid>
		<dc:creator>cheong</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/cheong/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">cheong said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">koistya said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>&gt; product.Name = <span class="string">&quot;T-Short&quot;</span>;<br>
&gt; product.Name.IsDirty</p>
<p>Actually there's nothing prevent you to use &quot;product.Name_IsDirty&quot;. That kind of extension makes so little in readability improvement so probably just not worth the effort to change.</p>
</div></blockquote>
<p>I can see a potential application with templates:</p>
<p>&nbsp;</p>
<p>struct DataProperty&lt;T TData&gt; {</p>
<p>&nbsp;</p>
<p>private TData _value;</p>
<p>public event EventHandler PropertyChanged;</p>
<p>public TData Value { get { return _value; } set { _value = value; PropertyChanged(this, EventArgs.Empty); IsDirty = true; }</p>
<p>public bool IsDirty { get; private set; }</p>
<p>&nbsp;</p>
<p>}</p>
<p>&nbsp;</p>
<p>class SomeBusinessObject {</p>
<p>&nbsp;</p>
<p>public DataProperty&lt;String&gt; Name { get; private set; }</p>
<p>&nbsp;</p>
<p>}</p>
<p>&nbsp;</p>
<p>What do you guys think?</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/38a0ba1bb80a4e94b5559dec00a8e907#38a0ba1bb80a4e94b5559dec00a8e907</link>
		<pubDate>Thu, 09 Sep 2010 05:22:28 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/38a0ba1bb80a4e94b5559dec00a8e907#38a0ba1bb80a4e94b5559dec00a8e907</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">W3bbo said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">cheong said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>I can see a potential application with templates:</p>
<p>&nbsp;</p>
<p>struct DataProperty&lt;T TData&gt; {</p>
<p>&nbsp;</p>
<p>private TData _value;</p>
<p>public event EventHandler PropertyChanged;</p>
<p>public TData Value { get { return _value; } set { _value = value; PropertyChanged(this, EventArgs.Empty); IsDirty = true; }</p>
<p>public bool IsDirty { get; private set; }</p>
<p>&nbsp;</p>
<p>}</p>
<p>&nbsp;</p>
<p>class SomeBusinessObject {</p>
<p>&nbsp;</p>
<p>public DataProperty&lt;String&gt; Name { get; private set; }</p>
<p>&nbsp;</p>
<p>}</p>
<p>&nbsp;</p>
<p>What do you guys think?</p>
</div></blockquote>
<ol>
<li>Doesn't compile </li><li>Doesn't work because it's a struct (foo.Name.Value = &quot;whatever&quot; would not change the value of Name but that of a temporary copy).
</li><li>Crashes if PropertyChanged is null. </li></ol></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/90bf306b93b149048a929dec00a8e935#90bf306b93b149048a929dec00a8e935</link>
		<pubDate>Thu, 09 Sep 2010 05:45:58 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/90bf306b93b149048a929dec00a8e935#90bf306b93b149048a929dec00a8e935</guid>
		<dc:creator>Sven Groot</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Sven Groot/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">koistya said:</div><div class="quoteText">
<h4><strong><a href="http://www.fsguy.com/2010-09-09_property-extensions-in-csharp-5-0">Property extensions in C# 5.0</a></strong></h4>
<p></p>
<pre class="brush: csharp">// A product type in this sample has a property Name of type String
var product = new Product();

// This will print &quot;Product.Name.IsDirty: False&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Now let's try to update product's Name property
product.Name = &quot;C# 4.0 in a Nutshell&quot;;

// And now this will print &quot;Product.Name.IsDirty: True&quot;
Console.WriteLine(&quot;Product.Name.IsDurty: {0}&quot;, product.Name.IsDirty);

// Then when you try to save this product in database, it will be easier for
// Store Repository detect which fields must be saved and which can be skipped
storeRepository.Add(product);
storeRepository.SubmitChanges();</pre>
<p></p>
</div></blockquote>
<p>what is a &quot;t-short&quot; ?</p>
<p>&nbsp;</p>
<p>and yes, it does sound dirty</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/bb5fb9bf1d504d2891a09dec00a8e962#bb5fb9bf1d504d2891a09dec00a8e962</link>
		<pubDate>Thu, 09 Sep 2010 14:32:36 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/bb5fb9bf1d504d2891a09dec00a8e962#bb5fb9bf1d504d2891a09dec00a8e962</guid>
		<dc:creator>Minh</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Minh/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Minh said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">koistya said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>what is a &quot;t-short&quot; ?</p>
<p>&nbsp;</p>
<p>and yes, it does sound dirty</p>
</div></blockquote>
<p><img src="http://files.myopera.com/TommyCarlier/albums/150463/t-short.png" alt="T-short" width="500" height="300"></p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0d542f89edc244c5a5ad9dec00a8e98c#0d542f89edc244c5a5ad9dec00a8e98c</link>
		<pubDate>Thu, 09 Sep 2010 15:03:06 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/0d542f89edc244c5a5ad9dec00a8e98c#0d542f89edc244c5a5ad9dec00a8e98c</guid>
		<dc:creator>Tommy Carlier</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/TommyCarlier/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">TommyCarlier said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Minh said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p><img src="http://files.myopera.com/TommyCarlier/albums/150463/t-short.png" alt="T-short" width="500" height="300"></p>
</div></blockquote>
<p>lmao</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9fa839ab593948b9856c9dec00a8e9b6#9fa839ab593948b9856c9dec00a8e9b6</link>
		<pubDate>Thu, 09 Sep 2010 15:08:49 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/9fa839ab593948b9856c9dec00a8e9b6#9fa839ab593948b9856c9dec00a8e9b6</guid>
		<dc:creator>Scott</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/spivonious/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">spivonious said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">TommyCarlier said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>lmao</p>
</div></blockquote>
<p>I ♥ Paint.NET</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/6467b14ea6a94ac0b6ce9dec00a8e9e1#6467b14ea6a94ac0b6ce9dec00a8e9e1</link>
		<pubDate>Thu, 09 Sep 2010 15:27:56 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/6467b14ea6a94ac0b6ce9dec00a8e9e1#6467b14ea6a94ac0b6ce9dec00a8e9e1</guid>
		<dc:creator>Tommy Carlier</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/TommyCarlier/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>Are we back on this topic again? Well, in that case I'd like to mention an idea I had that does away with all the arguments about &quot;can't come up with a decent syntax for extension properties&quot; argument. Instead of working at the property/method level, why
 not wrap the whole thing into a special type of extension class?</p>
<p>&nbsp;</p>
<p>For instance, we can have:</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">
partial class ClassA 
{ 
    private int total;

    public int Total 
    { 
        get { return total; }
        set { total = value; }
    } 

    public void Add(int value)
    {
        total &#43;= value;
    }

    // etc...
}</pre>
<p></p>
<p>&nbsp;</p>
<p>But why not have something like this:</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">
extension class ClassA 
{ 
    // private int total; // &lt;- The compiler won't allow adding new fields

    public int Total 
    { 
        get { return total; }
        set { total = value; }
    } 

    public void Add(int value)
    {
        total &#43;= value;
    }

    // etc...
}</pre>
<p></p>
<p>&nbsp;</p>
<p>So&nbsp;this proposed&nbsp;<strong>extension class</strong> is similar to the syntax&nbsp;of a
<strong>partial class</strong>, with some restrictions -&nbsp;notably if you add new fields, the compiler will generate an error. This mechanism has the advantage that there is almost nothing new for the developer to learn in order to use extension properties/methods.
 The syntax is exactly the same as if you wrote a partial class. In other words, other that just adding the word &quot;extension&quot; in front of the class declaration, the syntax is 100% standard and there is no need to come up with weird declarations&nbsp;at the&nbsp;methods/properties
 level.</p>
<p>&nbsp;</p>
<p>Also, the class/value&nbsp;instance should be passed by ref into the extension properties/methods, so that value types can change fields if they want to (non-withstanding some's belief that value types should be immutable -&nbsp;there are valid cases where&nbsp;you need
 them to be mutable).</p>
<p>&nbsp;</p>
<p>EDIT: For extending structs, you'd probably need to do:</p>
<p>&nbsp;</p>
<p></p>
<pre class="brush: csharp">
extension struct StructA
{
    //...
}</pre>
<p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d04acf49bdb64ad3b2349dec00a8ea15#d04acf49bdb64ad3b2349dec00a8ea15</link>
		<pubDate>Thu, 09 Sep 2010 15:52:15 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/d04acf49bdb64ad3b2349dec00a8ea15#d04acf49bdb64ad3b2349dec00a8ea15</guid>
		<dc:creator>BitFlipper</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/BitFlipper/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p>Big &#43;1 to BitFlipper's suggestion for handling all extension-X's. In general Extension Methods are great to have, but the original design is flawed. The existing implementation should be left available for existing code, but the future implementation should be as BitFlipper suggests above. It's straight-forward, it looks more like normal classes, and it doesn't leave you wondering from a design-perspective &quot;But what does an operator look like? But what does a property look like?&quot; which is a sign of its better suitability.</p><p>It's also more DRY - repeating yourself over and over with &quot;this MvcHtmlHelper html&quot; in every single extension method in an extension class isn't useful. You're not going to switch it up and refer to a different object you're extending in that extension class. You're just typing out a lot of extra characters in each method definition to suit an unfortunate design.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/ea353ba831fa49a5a8bd9f160020664f#ea353ba831fa49a5a8bd9f160020664f</link>
		<pubDate>Mon, 04 Jul 2011 01:57:57 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/ea353ba831fa49a5a8bd9f160020664f#ea353ba831fa49a5a8bd9f160020664f</guid>
		<dc:creator>b9chris</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/b9chris/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p></p><blockquote><div class="quoteText"><p></p><p><a class="permalink" title="Post Permalink" href="/Forums/Coffeehouse/257556-C-Extension-Properties/ea353ba831fa49a5a8bd9f160020664f">12 minutes&nbsp;ago</a>,<a href="/Niners/b9chris">b9chris</a> wrote</p><p>Big &#43;1 to BitFlipper's suggestion for handling all extension-X's. In general Extension Methods are great to have, but the original design is flawed. The existing implementation should be left available for existing code, but the future implementation should be as BitFlipper suggests above. It's straight-forward, it looks more like normal classes, and it doesn't leave you wondering from a design-perspective &quot;But what does an operator look like? But what does a property look like?&quot; which is a sign of its better suitability.</p><p>It's also more DRY - repeating yourself over and over with &quot;this MvcHtmlHelper html&quot; in every single extension method in an extension class isn't useful. You're not going to switch it up and refer to a different object you're extending in that extension class. You're just typing out a lot of extra characters in each method definition to suit an unfortunate design.</p><p></p></div></blockquote><p></p><p>It's a stab in the dark, but is your last name Rondot, by any chance?</p><p>IRT BitFlipper:</p><p>You <em>could</em> have extension fields: the compiler would create (behind the scenes) a static Dictionary&lt;TBase,Pair&lt;String,TField&gt;&gt; and do a lookup that way. But I suppose you could do that yourself if you wanted.</p><p>Your syntax is nice, but suffers from too-much-typing: often you want to add a single extension method to a whole load of types, or add extension methods to types besides classes and the current syntax is optimised for these scenarios.</p><p>Supporting both syntaxes would be better. As for myself, I want to have to explicitly opt-in to extension methods rather than them being implicitly-enabled by importing the namespace they're located in (i.e. you should explicitly import the containing static extension class).</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/7451b4b289fb454997209f1600240891#7451b4b289fb454997209f1600240891</link>
		<pubDate>Mon, 04 Jul 2011 02:11:11 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/7451b4b289fb454997209f1600240891#7451b4b289fb454997209f1600240891</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - C# Extension Properties?</title>
		<description><![CDATA[<p></p><blockquote><div class="quoteText"><p></p><p><a class="permalink" title="Post Permalink" href="/Forums/Coffeehouse/257556-C-Extension-Properties/7451b4b289fb454997209f1600240891">2 hours&nbsp;ago</a>,<a href="/Niners/W3bbo">W3bbo</a> wrote</p><p>Supporting both syntaxes would be better. As for myself, I want to have to explicitly opt-in to extension methods rather than them being<strong>implicitly-enabled by importing the namespace they're located in</strong> (i.e. you should explicitly import the containing static extension class).</p><p></p></div></blockquote><p></p><p>But that's not how it works. Multiple assemblies can share the same namespace. Using a namespace doesn't &quot;implicitly enable&quot; all the classes across different assemblies that happen to&nbsp;belong to the same namespace. If you don't reference the specific assembly in which the extension methods reside, you're not &quot;opting in&quot; to anything. So &quot;opting in&quot; is more granular than you're making it out to be.</p><p>Besides, you're free to seperate&nbsp;all your extension methods into different assemblies, which, in effect, would be like forcing you to import the classes individually. Nobody forces you to put all your extension methods into the same assembly or in the same assembly as the classes that they're extending.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/2b5c2157cada484185509f16005504f1#2b5c2157cada484185509f16005504f1</link>
		<pubDate>Mon, 04 Jul 2011 05:09:32 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/257556-C-Extension-Properties/2b5c2157cada484185509f16005504f1#2b5c2157cada484185509f16005504f1</guid>
		<dc:creator>cbae</dc:creator>
		<slash:comments>42</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/cbae/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>