C# compiler error: Inconsistent accessibility
Posted: (EET/GMT+2)
Late last night, I ran into the following C# compiler error when developing a piece of code with Visual Studio .NET 2005 Beta 2:
Inconsistent accessibility: parameter type 'nnn' is less accessible than method 'mmm'.
Why did this happen? I wondered a while, as the error message didn't seem to be very clear. But when you read it to the letter, it is.
That is, this error happens when you have a type that is less accessible (private instead of public, for example) than a method that uses this type as a parameter.
Say you have a parameter of type MyStruct. Now, the method that has this parameter is marked public. If MyStruct is private, you get the above error. Make MyStruct also public, and the error will go away! An easy fix, and reminds me why one should not write code while too sleepy!