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
Leave a Comment

(required) 

(required) 

(optional)

(required)