Visual Studio 2010 - Visual C#
Compiler Error CS0051
Inconsistent accessibility: parameter type 'type' is less accessible than method 'method'
The return type and each of the types referenced in the formal parameter list of a method must be at least as accessible as the method itself. Make sure the types used in method signatures are not accidentally private due to the omission of the public modifier. For more information, see Access Modifiers (C# Programming Guide).
Example
The following sample generates CS0051:
// CS0051.cs
public class A
{
// Try making B public since F is public
// B is implicitly private here
class B
{
}
public static void F(B b) // CS0051
{
}
public static void Main()
{
}
}
Community Content
Mistralys
Check class declaration and method declaration
I got this message as well, and in my case it was because I had a public method that I gave an object whose class declaration was not public:
$0$0
$0
$0class Gallery$0
$0{$0
$0}$0
$0$0
$0
$0class GalleryForm$0
$0{$0
$0 public void setGallery( Gallery gallery )$0
$0 {$0
$0 // code here$0
$0 }$0
$0}$0
$0$0
$0
$0Gallery gallery = new Gallery();$0
$0GalleryForm form = new GalleryForm();$0
$0$0
$0
$0form->setGallery( gallery ); // giving a public method a non-public object$0
$0$0
$0
$0I had not implicitly set the class gallery to public, so adding it to the class declaration solved the issue:$0
$0$0
$0
$0public class gallery$0
$0{$0
$0}$0