开发者

First time with this error - Inconsistent accessibility

This is my first time working with interfaces and proper namespace structure. When I compile I get the error below, I have no idea what it means. Any searches I do shows up private public issues but both are public. Any ideas?

Error Inconsistent accessibility: return type 'System.Collections.Generic.List' is less accessible than method 'Webtext.ApplicationEntities.Implementations.AdditionalEntities.UrlBuilderO2.GetUrlRequests (string, string, string, string)' C:\Users\Laptop\documents\visual studio 2010\Projects\Webtext\Webtext\ApplicationEntities\Implementations\AdditionalEntities\UrlBuilderO2.cs 19 39 Webtext

The Code files are:

namespace Webtext.ApplicationEntities.Interfaces
{
    interface IUrlBuilder
    {
       List<IOperatorRequest> GetUrlRequests(string UserName, string Password, string MessageRecipient, string Message);
    }
}

And:

namespace Webtext.ApplicationEntities.Implementations.AdditionalEntities
{
    public class UrlBuilderO2: IUrlBuilder
    {

        public List<IOperatorRequest> GetUrlRequests(string UserName, string Password, string MessageRecipient, string Message)
        {
            throw new NotImplementedException();
        }
    }
}

Namespace Structure

Webtext

ApplicationEntities

     Interfaces
          ##### INTERFACE IS HE开发者_JAVA技巧RE

     Implementations

          AdditionalEntities
               ##### URL BUILDER IS HERE


You have a public property on a public class that exposes a list of non-public types.
You need to change IOperatorRequest to be public or change the UrlBuilderO2 class or GetUrlReuests method to be non-public.


The problem is IOperatorRequest is probably internal.

UPDATE

What I said is correct. Omitting modifier makes it internal.

Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified.


IOperatorRequest is internal which is less accessible than public.

Top-level types, which are not nested in other types, can only have internal or public accessibility. The default accessibility for these types is internal.

from MSDN

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜