Faraz Shah Khan

MCP, MCAD.Net, MCSD.Net, MCTS-Win, MCTS-Web, MCPD-Web

Error: Inconsistent accessibility: return type

In one of my projects I found this error Inconsistent accessibility: return type...................... is less accessible than method ......... It was a quite strange error for me as I have not seen the same in past. My classes were defined as:

class MyClass1
{}

class MyClass2
{}

class MyClass3
{}

Solution to this problem is very easy, all I did is add public with all my classes.

public class MyClass1
{}

public class MyClass2
{}

public class MyClass3
{}

And once again, the day is saved by "Powerpuf Girls", I mean by adding public :).

Comments

JV said:

In your case, you were returning a private class in a public method. That indeed won't work, unless the class is also public :)

# June 16, 2009 8:12 AM

ryan said:

I'm inheriting from List<>, which is not public. If I change the child class to public, I get the error still. An ideas?

# December 8, 2009 8:19 PM

Jocke said:

Thanks JV. Your comment solved my problems.

# March 19, 2010 11:01 AM

panos said:

you are sooo right..thanks

# May 19, 2010 8:28 PM

kikus said:

как всегда на высоте

# June 13, 2010 3:20 PM

Romo said:

Thanks, a really interesting read – added to bookmarks so will check back for new content and to read other

people’s comments. Cheers again.

# December 22, 2012 4:16 AM

Bucher said:

This is certainly my initial stop by and I really along the

lines of what I’m seeing. Your weblog is so much fun to look over, quite compelling as well

because informative. I’ll undoubtedly recommend it to my friends.

Nevertheless, I did have some question with the commenting.

It kept giving me an question whenever I clicked

on publish comment. I hope, that can be fixed. A whole lot of thanks

# January 8, 2013 9:40 PM

Harter said:

I conceive this web site holds very excellent indited content material posts .

# January 8, 2013 11:44 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)