Skip to content

Error CS0051: Inconsistent accessibility

George George

Asked Jun 22, 2008, 9:22 PM EDT4 answers
Share
LinkedInX

Hello everyone,


For the following code, the compile error is,

[Code]
error CS0051: Inconsistent accessibility: parameter type 'TestEnum1.Goo.Level' is less accessible than method 'TestEnum1.Foo.Test(TestEnum1.Goo.Level)'
[/Code]

My fix is to make class Goo public, is it correct fix? Why there is such compile error?

[Code]
    class Goo
    {
        public enum Level
        {
            Error = 0,
            Warning = 1
        }
    }

    public class Foo
    {
        static public void Test(TestEnum1.Goo.Level l)
        {
            return;
        }
    }
[/Code]


thanks in advance,
George

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    The problem is that the method parameters must be no law accessible than the method itself. else error CS0051: Inconsistent accessibility you know that if you define a class without access param they are marked as internal and internal is law than public
    in your case the class is internal and the members are publics
    0
  • 0
    Thanks man!


    I have did some search in MSDN, about access modifier for class level, other than for method level. But I can not find any information. Any recommended links? I feel as you said, the root cause is my knowledge about access modifier for class level.


    regards,
    George
    0
  • Bechir Bejaoui
    0
    I think yes but anyway it's not a big issue
    0
  • 0

    Thanks Bechir,

     

    Can I understand the root cause of my original issue in this way? The class is not public (default private?) and the type inside the class is public -- more visibility then outer type?


    regards,
    George

    0