Why can't the constructor of a universal class with the enum parameter call the protected methods of this class by default?

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, target .NET4.0) gives an error when called from Test() to DoSomething() . If I remove the default option on TestEnum a , it will be just fine. MonoDevelop wants to call the default parameter TestEnum<>.A , but it does not compile, and does not matter TestEnum<T>.A (obviously, I would not expect them to work, but using MonoDevelop autocomplete, what I get) .

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

+7
source share
1 answer

As stated in the comments, this is a compiler error.

It seems that your Mono development environment is not very similar to a protected keyword.

Use {public, private} for now.

+1
source

All Articles