error CS0051: Inconsistent accessibility

This is a discussion on error CS0051: Inconsistent accessibility within the C# Programming forums, part of the General Programming Boards category; Hello everyone, For the following code, the compile error is, Code: error CS0051: Inconsistent accessibility: parameter type 'TestEnum1.Goo.Level' is less ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    error CS0051: Inconsistent accessibility

    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)'
    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;
            }
        }

    thanks in advance,
    George

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Not a C# person, but I can't see any good reason to have a method available where the parameter type is not in scope. That is, in the main program, you can see that there is a function called Test, but won't have any way to pass it anything, since TestEnum1.Goo.Level isn't a legitimate type at that point of the program.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    My fix is to make class Goo public, is it correct fix? Why there is such compile error?
    Yes, that's correct. Either make Goo public or make the Test method less accessible (same scope as Goo), because it makes no sense to have a public method, that no one can call because the parameter types are not public.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inconsistent (and wrong) output using boost::thread
    By Fox5 in forum C++ Programming
    Replies: 2
    Last Post: 12-29-2008, 12:42 AM
  2. Accessibility and automation technologies - which to prefer?
    By midix in forum Windows Programming
    Replies: 4
    Last Post: 10-05-2007, 01:33 PM
  3. Inconsistent Compilation
    By GlassEyeSlim in forum Linux Programming
    Replies: 2
    Last Post: 02-23-2006, 05:43 PM
  4. Inconsistent type declaration
    By randdoni in forum C Programming
    Replies: 1
    Last Post: 05-15-2003, 02:05 PM
  5. Inconsistent errors - MSVC++ 6
    By AeroHammer in forum C++ Programming
    Replies: 2
    Last Post: 05-06-2003, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21