Why is the constructor of a generic class with a default-valued enum parameter not able to call protected methods of that class?

Viewed 394

A simple test case:

using System;

public class Test<T>
{
    public enum TestEnum
    {
        A,
        B
    }
    public Test (TestEnum a = TestEnum.A)
    {
        DoSomething ();
    }

    protected void DoSomething()
    {
    }
}

The compiler (this is using Mono in a Unity3D project, .NET4.0 target) gives an error on the call in Test() to DoSomething(). If I remove the default parameter on TestEnum a, it builds just fine. MonoDevelop wants to call the default parameter TestEnum<>.A, but that doesn't compile, neither does TestEnum<T>.A (obviously I wouldn't have expected these to work but using MonoDevelop's autocomplete that's what I get).

EDIT: the specific error is: the name DoSomething doesn't exists in the current context

1 Answers
Related