<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>A Note about Enums (Scott Wisniewski)</title><link>http://blogs.msdn.com/vbteam/archive/2007/10/15/a-note-about-enums-scott-wisniewski.aspx</link><description>I recently received an email from a customer who had a few questions about "enum inheritance" in VB, specifically as to why it wasn't supported. In particular, he sent us the following snippet of VB code (I've changed the names of the classes and methods</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MSDN Blog Postings  &amp;raquo; A Note about Enums (Scott Wisniewski)</title><link>http://blogs.msdn.com/vbteam/archive/2007/10/15/a-note-about-enums-scott-wisniewski.aspx#5464658</link><pubDate>Tue, 16 Oct 2007 01:14:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5464658</guid><dc:creator>MSDN Blog Postings  » A Note about Enums (Scott Wisniewski)</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2007/10/15/a-note-about-enums-scott-wisniewski/"&gt;http://msdnrss.thecoderblogs.com/2007/10/15/a-note-about-enums-scott-wisniewski/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: A Note about Enums (Scott Wisniewski)</title><link>http://blogs.msdn.com/vbteam/archive/2007/10/15/a-note-about-enums-scott-wisniewski.aspx#5469284</link><pubDate>Tue, 16 Oct 2007 12:17:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5469284</guid><dc:creator>Kim Major</dc:creator><description>&lt;p&gt;I believe I got the context of the question, but I feel that the answer slightly misses the point. While technically correct, the problem in the question would IMHO better be solved by following a few simple principles leading to better code in the first place.&lt;/p&gt;
&lt;p&gt;Extract what varies. In this case the variation is the DoSomethingXXX().&lt;/p&gt;
&lt;p&gt;If the base class had a reference to an IDoSomething.&lt;/p&gt;
&lt;p&gt;eg. Dim MyDoer as IDoSomething&lt;/p&gt;
&lt;p&gt;then instead of switching on the enum he could just call MyDoer.DoSomething where the MyDoer is a concrete implementation of whatever action needs to be carried out.&lt;/p&gt;
&lt;p&gt;This would also shield the base class from changes when a DoSomethingXYZ comes around.&lt;/p&gt;
</description></item><item><title>re: A Note about Enums (Scott Wisniewski)</title><link>http://blogs.msdn.com/vbteam/archive/2007/10/15/a-note-about-enums-scott-wisniewski.aspx#5469483</link><pubDate>Tue, 16 Oct 2007 12:36:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5469483</guid><dc:creator>Michael Feld</dc:creator><description>&lt;p&gt;While I can see why you can't inherit from enum types, what I'd really like do is constrain on enum types, such as:&lt;/p&gt;
&lt;p&gt;Public Class Foo(Of T As System.Enum)&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;End Class&lt;/p&gt;
&lt;p&gt;This would ensure that T will be supported in the System.Enum.GetNames() method, for example. Plus, you can always cast it to an Object.&lt;/p&gt;
</description></item></channel></rss>