<?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"
	>
<channel>
	<title>Comments on: Extension Methods in Vb.Net and C#</title>
	<atom:link href="http://blog.gadodia.net/extension-methods-in-vbnet-and-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/</link>
	<description>"... tech .... fun .. bizarre ... india .... pictures ..... anything in the world ...."</description>
	<pubDate>Fri, 05 Dec 2008 14:03:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9867</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Thu, 28 Aug 2008 21:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9867</guid>
		<description>@Rick.. oh well, its back to the old status for me then...</description>
		<content:encoded><![CDATA[<p>@Rick.. oh well, its back to the old status for me then&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick E</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9866</link>
		<dc:creator>Rick E</dc:creator>
		<pubDate>Thu, 28 Aug 2008 17:59:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9866</guid>
		<description>This is an old article. I know this isn't true because I have a few extension methods off of system.object.</description>
		<content:encoded><![CDATA[<p>This is an old article. I know this isn&#8217;t true because I have a few extension methods off of system.object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9865</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Thu, 28 Aug 2008 17:13:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9865</guid>
		<description>@John, I didn't realize that... thanks for pointing that out though... of course, I was being a bit melodramatic back there, but it does make it a little better :D</description>
		<content:encoded><![CDATA[<p>@John, I didn&#8217;t realize that&#8230; thanks for pointing that out though&#8230; of course, I was being a bit melodramatic back there, but it does make it a little better <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Moreno</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9864</link>
		<dc:creator>John Moreno</dc:creator>
		<pubDate>Thu, 28 Aug 2008 16:31:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9864</guid>
		<description>If it makes you feel any better, there's something you can do in C# that you can't do in VB: create an extension method that works on System.Object.

See this blog from the VBTeam:
http://blogs.msdn.com/vbteam/archive/2007/01/24/extension-methods-and-late-binding-extension-methods-part-4.aspx</description>
		<content:encoded><![CDATA[<p>If it makes you feel any better, there&#8217;s something you can do in C# that you can&#8217;t do in VB: create an extension method that works on System.Object.</p>
<p>See this blog from the VBTeam:<br />
<a href="http://blogs.msdn.com/vbteam/archive/2007/01/24/extension-methods-and-late-binding-extension-methods-part-4.aspx" rel="nofollow">http://blogs.msdn.com/vbteam/archive/2007/01/24/extension-methods-and-late-binding-extension-methods-part-4.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9446</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Wed, 23 Jul 2008 15:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9446</guid>
		<description>I am glad that you see it the same way Rick (the first part).

I always liked Maths better than literature in High School, so I guess that's why I like C# better :)

Thanks for all your comments.</description>
		<content:encoded><![CDATA[<p>I am glad that you see it the same way Rick (the first part).</p>
<p>I always liked Maths better than literature in High School, so I guess that&#8217;s why I like C# better <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks for all your comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick E</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9445</link>
		<dc:creator>Rick E</dc:creator>
		<pubDate>Wed, 23 Jul 2008 13:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9445</guid>
		<description>I agree both languages should work the same and both be capable of the same thing. However the real world just doesn't work that way. So while both languages are extremely close, there will always be some scenarios/features that will favor one over the other. This particular example is probably a bug that will be addressed in the future

For me I prefer the readability and self documenting. If you have ever had to come back to something you wrote 10+ years ago and try to figure out what you did. You will greatly appreciate those features. Granted you can do a lot of that in C# too with a little extra effort, but it's not as natural as in VB. VB reads more like English, while C# reads more like math to me. I use both, but I prefer VB for the vast majority of my projects.</description>
		<content:encoded><![CDATA[<p>I agree both languages should work the same and both be capable of the same thing. However the real world just doesn&#8217;t work that way. So while both languages are extremely close, there will always be some scenarios/features that will favor one over the other. This particular example is probably a bug that will be addressed in the future</p>
<p>For me I prefer the readability and self documenting. If you have ever had to come back to something you wrote 10+ years ago and try to figure out what you did. You will greatly appreciate those features. Granted you can do a lot of that in C# too with a little extra effort, but it&#8217;s not as natural as in VB. VB reads more like English, while C# reads more like math to me. I use both, but I prefer VB for the vast majority of my projects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9440</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Wed, 23 Jul 2008 04:08:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9440</guid>
		<description>@Rick.. Well, I don't want to say that I am totally a C# guy. I like it a lot better than VB. I have worked on VB at work.

Incidentally, the reason I describe it as a flaw in VB is because of what I read on the VB Team Blog (http://blogs.msdn.com/vbteam/archive/2007/01/05/extension-methods-part-2.aspx). Here they talk about making a design change while implementing extension methods in VB to bring the behavior at a parity with what it is in C#.

If there needs to be consistency in this approach, then allowing ByRef, which is something that is not possible to do in C# (even if you are using an extension method defined in a VB module), would break such a parity.

It's not just a language thing. Imagine (for argument's sake) how an API developed in VB.Net that makes use of extension methods would break if consumed from C# because it used a ByRef parameter.

There are differences in VB and C#, and most of them are style differences, but one like this doesn't make sense at all. At their core, the languages are supposed to be the same, and it shouldn't matter which one I develop in. But a difference like this can make it matter, right? (given my API example above).

Cheers.

@Chad... yes, I agree.</description>
		<content:encoded><![CDATA[<p>@Rick.. Well, I don&#8217;t want to say that I am totally a C# guy. I like it a lot better than VB. I have worked on VB at work.</p>
<p>Incidentally, the reason I describe it as a flaw in VB is because of what I read on the VB Team Blog (http://blogs.msdn.com/vbteam/archive/2007/01/05/extension-methods-part-2.aspx). Here they talk about making a design change while implementing extension methods in VB to bring the behavior at a parity with what it is in C#.</p>
<p>If there needs to be consistency in this approach, then allowing ByRef, which is something that is not possible to do in C# (even if you are using an extension method defined in a VB module), would break such a parity.</p>
<p>It&#8217;s not just a language thing. Imagine (for argument&#8217;s sake) how an API developed in VB.Net that makes use of extension methods would break if consumed from C# because it used a ByRef parameter.</p>
<p>There are differences in VB and C#, and most of them are style differences, but one like this doesn&#8217;t make sense at all. At their core, the languages are supposed to be the same, and it shouldn&#8217;t matter which one I develop in. But a difference like this can make it matter, right? (given my API example above).</p>
<p>Cheers.</p>
<p>@Chad&#8230; yes, I agree.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9436</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Tue, 22 Jul 2008 21:04:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9436</guid>
		<description>Principle of Least Surprise. The VB automatic ByRef semantics can be a nightmare. I pass in my value for x and suddenly x is a totally different object reference. I didn't specify 'ref', it just automagically happened.

Likewise with x.SomeExtMethod() causing x to be a pointer/reference to totally different object is horrible for code clarity and solubility. 

Magic pointers are bad and lead to instability and surprises in code.  I'm not saying VB is bad, but I *AM* saying that magic pointers are bad. This problem existed in C/C++ and it was bad there too.

C# doesn't have this bug for precisely the reasons I mentioned above.</description>
		<content:encoded><![CDATA[<p>Principle of Least Surprise. The VB automatic ByRef semantics can be a nightmare. I pass in my value for x and suddenly x is a totally different object reference. I didn&#8217;t specify &#8216;ref&#8217;, it just automagically happened.</p>
<p>Likewise with x.SomeExtMethod() causing x to be a pointer/reference to totally different object is horrible for code clarity and solubility. </p>
<p>Magic pointers are bad and lead to instability and surprises in code.  I&#8217;m not saying VB is bad, but I *AM* saying that magic pointers are bad. This problem existed in C/C++ and it was bad there too.</p>
<p>C# doesn&#8217;t have this bug for precisely the reasons I mentioned above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick E</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9435</link>
		<dc:creator>Rick E</dc:creator>
		<pubDate>Tue, 22 Jul 2008 19:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9435</guid>
		<description>"I think, it’s never meant to be ByRef, and it’s a VB flaw that allows it to be ByRef"

Typical of a C# guy to think it's a flaw in VB. Why can't it be a flaw in C#? Which it is! C# programmers make mistakes too, even if they don't think so.

Having learned many languages over my career, I always find the arrogance of C# guys funny.</description>
		<content:encoded><![CDATA[<p>&#8220;I think, it’s never meant to be ByRef, and it’s a VB flaw that allows it to be ByRef&#8221;</p>
<p>Typical of a C# guy to think it&#8217;s a flaw in VB. Why can&#8217;t it be a flaw in C#? Which it is! C# programmers make mistakes too, even if they don&#8217;t think so.</p>
<p>Having learned many languages over my career, I always find the arrogance of C# guys funny.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9434</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Tue, 22 Jul 2008 18:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9434</guid>
		<description>Randolpho, yes that was the problem, and I guess I was too quick to write it off (I was already frustrated at the ByRef problem).

Incidentally, here's a new thing: If I have used ByRef in the VB Extension method, I still can't use it from C#, because I get an error message saying "Argument one must be passed with the "ref" keyword". And since I am calling this as an extension method, I can't qualify the parameter :)

I think, it's never meant to be ByRef, and it's a VB flaw that allows it to be ByRef.

Cheers.</description>
		<content:encoded><![CDATA[<p>Randolpho, yes that was the problem, and I guess I was too quick to write it off (I was already frustrated at the ByRef problem).</p>
<p>Incidentally, here&#8217;s a new thing: If I have used ByRef in the VB Extension method, I still can&#8217;t use it from C#, because I get an error message saying &#8220;Argument one must be passed with the &#8220;ref&#8221; keyword&#8221;. And since I am calling this as an extension method, I can&#8217;t qualify the parameter <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I think, it&#8217;s never meant to be ByRef, and it&#8217;s a VB flaw that allows it to be ByRef.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randolpho</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9433</link>
		<dc:creator>Randolpho</dc:creator>
		<pubDate>Tue, 22 Jul 2008 17:47:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9433</guid>
		<description>I'm afraid Peter's wrong; it *can* be called just like a normal extension method -- I've just successfully tested it. 

I ran into problems trying to test it, though, so let me give you a walkthrough of my successful test:

1) First, I created a VB.Net project in a scratch solution called "Extenders" with a default namespace of "Extenders"
2) Next, I created a module which I didn't bother renaming "Module1"
3) Within that, I created a simple extension method that adds the phrase "Hello World!" to a string. Here is the full code:

Imports System.Runtime.CompilerServices

Public Module Module1
  &#60;Extension()&#62; Public Function AddHello(ByVal val As String) As String
    Return val + "Hello World!"
  End Function
End Module

4) Finally, I created a simple C# application to call it, adding a reference to the Extenders project. Here's the complete code:

using System;
using Extenders;
namespace ExtenderTest
{
  public class TestExtender
  {
    public static string TestAddHello()
    {
       string test = "Test";
       return test.AddHello();
       // returns "TestHello World!"
    }    
  }
}


I mentioned trouble; the trouble was my natural C#-oriented inclination to add a namespace declaration to my code. 

I had noticed that Visual Studio hadn't added a namespace declaration to Module1.vb when I had created it, so I had inserted it myself, like this:

Imports System.Runtime.CompilerServices

Namespace Extenders
  Public Module Module1
    &#60;Extension()&#62; Public Function AddHello(ByVal val As String) As String
      Return val + "Hello World!"
    End Function
  End Module
End Namespace

My test code (as shown in step 4 above) failed to compile. After confirming that I *should* be able to do it via google, I started messing around, and eventually got my C# code to compile as follows:

using System;
using Extenders.Extenders; // &#60;-- the difference is here!
namespace ExtenderTest
{
  public class TestExtender
  {
    public static string TestAddHello()
    {
       string test = "Test";
       return test.AddHello();
       // returns "TestHello World!"
    }    
  }
}

I pointed out the difference with a comment, since it's a little subtle. It turns out that VB implicitly adds the default namespace specified in the project properties to any namespace declarations in code. Freaky, that -- I'm too used to explicit declarations. Now, I don't know if that's the problem you ran into, but I have verified that once you get the namespace using statement correct, the extension methods do, in fact, attach to the proper types.</description>
		<content:encoded><![CDATA[<p>I&#8217;m afraid Peter&#8217;s wrong; it *can* be called just like a normal extension method &#8212; I&#8217;ve just successfully tested it. </p>
<p>I ran into problems trying to test it, though, so let me give you a walkthrough of my successful test:</p>
<p>1) First, I created a VB.Net project in a scratch solution called &#8220;Extenders&#8221; with a default namespace of &#8220;Extenders&#8221;<br />
2) Next, I created a module which I didn&#8217;t bother renaming &#8220;Module1&#8243;<br />
3) Within that, I created a simple extension method that adds the phrase &#8220;Hello World!&#8221; to a string. Here is the full code:</p>
<p>Imports System.Runtime.CompilerServices</p>
<p>Public Module Module1<br />
  &lt;Extension()&gt; Public Function AddHello(ByVal val As String) As String<br />
    Return val + &#8220;Hello World!&#8221;<br />
  End Function<br />
End Module</p>
<p>4) Finally, I created a simple C# application to call it, adding a reference to the Extenders project. Here&#8217;s the complete code:</p>
<p>using System;<br />
using Extenders;<br />
namespace ExtenderTest<br />
{<br />
  public class TestExtender<br />
  {<br />
    public static string TestAddHello()<br />
    {<br />
       string test = &#8220;Test&#8221;;<br />
       return test.AddHello();<br />
       // returns &#8220;TestHello World!&#8221;<br />
    }<br />
  }<br />
}</p>
<p>I mentioned trouble; the trouble was my natural C#-oriented inclination to add a namespace declaration to my code. </p>
<p>I had noticed that Visual Studio hadn&#8217;t added a namespace declaration to Module1.vb when I had created it, so I had inserted it myself, like this:</p>
<p>Imports System.Runtime.CompilerServices</p>
<p>Namespace Extenders<br />
  Public Module Module1<br />
    &lt;Extension()&gt; Public Function AddHello(ByVal val As String) As String<br />
      Return val + &#8220;Hello World!&#8221;<br />
    End Function<br />
  End Module<br />
End Namespace</p>
<p>My test code (as shown in step 4 above) failed to compile. After confirming that I *should* be able to do it via google, I started messing around, and eventually got my C# code to compile as follows:</p>
<p>using System;<br />
using Extenders.Extenders; // &lt;&#8211; the difference is here!<br />
namespace ExtenderTest<br />
{<br />
  public class TestExtender<br />
  {<br />
    public static string TestAddHello()<br />
    {<br />
       string test = &#8220;Test&#8221;;<br />
       return test.AddHello();<br />
       // returns &#8220;TestHello World!&#8221;<br />
    }<br />
  }<br />
}</p>
<p>I pointed out the difference with a comment, since it&#8217;s a little subtle. It turns out that VB implicitly adds the default namespace specified in the project properties to any namespace declarations in code. Freaky, that &#8212; I&#8217;m too used to explicit declarations. Now, I don&#8217;t know if that&#8217;s the problem you ran into, but I have verified that once you get the namespace using statement correct, the extension methods do, in fact, attach to the proper types.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9432</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Tue, 22 Jul 2008 17:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9432</guid>
		<description>Here's what I am talking about: http://www.eggheadcafe.com/community/aspnet/2/10044580/extension-methods.aspx</description>
		<content:encoded><![CDATA[<p>Here&#8217;s what I am talking about: <a href="http://www.eggheadcafe.com/community/aspnet/2/10044580/extension-methods.aspx" rel="nofollow">http://www.eggheadcafe.com/community/aspnet/2/10044580/extension-methods.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randolpho</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9431</link>
		<dc:creator>Randolpho</dc:creator>
		<pubDate>Tue, 22 Jul 2008 16:55:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9431</guid>
		<description>Yeah, the ByVal/ByRef at will thing is pretty much the biggest selling point for me for VB. That and the My namespace. :)

It's not enough for me to overcome the nasty VB syntax, though. :D

That VB importation thing worries me, though. VB extension methods should work in C#. Let me go test that and get back to you.</description>
		<content:encoded><![CDATA[<p>Yeah, the ByVal/ByRef at will thing is pretty much the biggest selling point for me for VB. That and the My namespace. <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s not enough for me to overcome the nasty VB syntax, though. <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>That VB importation thing worries me, though. VB extension methods should work in C#. Let me go test that and get back to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9430</link>
		<dc:creator>Vaibhav</dc:creator>
		<pubDate>Tue, 22 Jul 2008 16:34:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9430</guid>
		<description>Hi Randolpho,

Let me put it this way. Enums aside, I can't pass any type by Refernce in an extension method in C#, while in Vb.Net I can. So, while I agree with all of you that maybe an enum is not the best example of demonstrating this and my original goal was probably not the best of ideas (my defense aside), the main point is the significant difference in the two languages when it comes to extension methods.

That is my only point of contention. Actually, it's not the only one. There is one more thing that I tried which left me even more exasperated (and I mention it at the end of my post). When I declared extension methods in a VB class library project, and imported it in a C# application, the extension methods did not attach to their types. I had to call them explicitly (ModuleName.MethodName(type_extended)).

While if I do the opposite (extension methods created in # and imported in VB) they work as expected.

Well, life's tough I guess :)</description>
		<content:encoded><![CDATA[<p>Hi Randolpho,</p>
<p>Let me put it this way. Enums aside, I can&#8217;t pass any type by Refernce in an extension method in C#, while in Vb.Net I can. So, while I agree with all of you that maybe an enum is not the best example of demonstrating this and my original goal was probably not the best of ideas (my defense aside), the main point is the significant difference in the two languages when it comes to extension methods.</p>
<p>That is my only point of contention. Actually, it&#8217;s not the only one. There is one more thing that I tried which left me even more exasperated (and I mention it at the end of my post). When I declared extension methods in a VB class library project, and imported it in a C# application, the extension methods did not attach to their types. I had to call them explicitly (ModuleName.MethodName(type_extended)).</p>
<p>While if I do the opposite (extension methods created in # and imported in VB) they work as expected.</p>
<p>Well, life&#8217;s tough I guess <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randolpho</title>
		<link>http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9429</link>
		<dc:creator>Randolpho</dc:creator>
		<pubDate>Tue, 22 Jul 2008 16:16:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.gadodia.net/extension-methods-in-vbnet-and-c/#comment-9429</guid>
		<description>I'm a little late to the discussion, but here's two cents:

Although yes, VB can do something C# can't (it does occasionally happen! ;) ), in this particular case I would argue along with the others that you shouldn't do things the way you initialy wanted to do them. 

Enumerations are designed to be read-only value types, similar to integers (which they are, under the covers), booleans, and floats. Extension methods to enumerations should follow that paradigm -- they should not modify the underlying value, they should return a new, updated value. Although you would always know that the method operates on the instance itself, the average person maintaining your code would expect different execution.

I would argue that the method you linked to in your first reply is the best method of parsing an enumeration, even though it extends string rather than Enums. It has problems though; you cannot constrain a generic method against the type Enum. I don't quite know *why* you can't do it, but the C# compiler balks with "Constraint cannot be special class 'System.Enum'" for some reason. That means the linked method has to check the type and throw an ArgumentException, and that just doesn't make sense, in my opinion. I mean, is the generic type actually an argument to the method call?</description>
		<content:encoded><![CDATA[<p>I&#8217;m a little late to the discussion, but here&#8217;s two cents:</p>
<p>Although yes, VB can do something C# can&#8217;t (it does occasionally happen! <img src='http://blog.gadodia.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ), in this particular case I would argue along with the others that you shouldn&#8217;t do things the way you initialy wanted to do them. </p>
<p>Enumerations are designed to be read-only value types, similar to integers (which they are, under the covers), booleans, and floats. Extension methods to enumerations should follow that paradigm &#8212; they should not modify the underlying value, they should return a new, updated value. Although you would always know that the method operates on the instance itself, the average person maintaining your code would expect different execution.</p>
<p>I would argue that the method you linked to in your first reply is the best method of parsing an enumeration, even though it extends string rather than Enums. It has problems though; you cannot constrain a generic method against the type Enum. I don&#8217;t quite know *why* you can&#8217;t do it, but the C# compiler balks with &#8220;Constraint cannot be special class &#8216;System.Enum&#8217;&#8221; for some reason. That means the linked method has to check the type and throw an ArgumentException, and that just doesn&#8217;t make sense, in my opinion. I mean, is the generic type actually an argument to the method call?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
