Saturday, November 17, 2007

Inconsistent accessibility: base class is less accessible than class

I was doing some coding in c#. I had one class but decided to split it up so I could reuse some of the functionality later. So I made a simple shell and started moving pieces into the parent class.

On my first compile I got this message: Inconsistent accessibility: base class is less accessible than class

I am a little rusty with my C# and classes, but it turns out I left off the public keyword on the new class. Adding public fixed that compile error.

16 comments:

Anonymous said...

I had this same error, arrrg, that was annoying, i sat there for awhile looking at my controller and DAL and couldnt figure it out. I looked up the error and got your site, thanks for the help :)

Anonymous said...

Same here...
Got the error, started Google, found you within seconds and problem solved XD
Thanks!

And now I see some other interesting stuff on your site, so lets have a look at that :D

Greg said...

Same deal as previous posters. Thanks for the help.

Anonymous said...

Ah, thanks, me too!

Anonymous said...

Thanks. I just assumed classes were public by default.

assesSaved++;

Chris Sheldon said...

I fell into the same trap, thanks for a rapid solution!

Anonymous said...

perfect! thanks for the help!

Anonymous said...

I just ran into this same problem while working on a lab in the 70-528 MCTS book. When you first bring up the code-behind the first class does not have the public infront of it. Of course, in Visual Studio, the default is Public. I added the public in front of the class in question and boom! It worked.

Anonymous said...

You trully saved me!!! Thanks!!

Tony Visconti said...

I'm such a failboat, thanks for the great help

psychuil said...

I love you man :D
Just saved me a really big headache

Anonymous said...

I had this error too but the class and instantiation of the class were both declared as public. However, the instantiation was using an enumber as one of the parameters and the enumbers were not declared as public. Made 'em public - jobs a good 'un. Just something else to look out for!

Anonymous said...

i had the same error, thanks for the post!

Anonymous said...

Same error

Shirley Hicks said...

Tripped across this five years later. Have the same problem, except that in my case, I'm calling an object class from a class that I'm using to build a list, both are public all the way down and I'm _still_ getting the error.

Hunting for the solution.....

Shirley Hicks

Anonymous said...

thanx buddie you just saved me :)