ILoggable

A place to keep my thoughts on programming

September 24, 2005 .net

VS.NET 2003 to 2005

I recently started playing with VS.NET 2005 Beta 2, mostly because I wanted to see the Class Designer in action. The first, pleasant surprise was that it co-exists peacefully with VS.NET 2003. I was afraid i might hose my daily dev environment with this experiment, but it seems to be ok. Haven’t tried ASP.NET yet, since the switch, but i hear that IIS is the one bone of contention with peaceful co-existence.

But enough about the pleasantries. Converting some work projects, i came across a C# language change that I’m not sure is a change or a fix for a bug. Either way it makes me change my code…

namespace ConsoleTester
{
    public class Base
    {
        protected Base()
        {
        }

        protected Base(string x)
        {
        }
    }

    public class Child : Base
    {
        private Child()
        {
        }

        public Base MakeBase()
        {
            return new Base("foo");
        }
    }
}

This works in C# 1.0, but in C# 2.0 i get Cannot access protected member ‘ConsoleTester.Base.Base()’ via a qualifier of type ‘ConsoleTester.Base’; the qualifier must be of type ‘ConsoleTester.Child’ (or derived from it). So is this a change in the spec, a bug in 1.0 or a bug in 2.0?

Leave a comment