Link to home
Start Free TrialLog in
Avatar of larkydoo
larkydoo

asked on

Method Inaccessible due to its protection level

I'm working in C#/ASP.net and have a BizObject class with the following method:

        protected static string ConvertNullToEmptyString(string input)
        {
            return (input == null ? "" : input);
        }

I am trying to call the method as stringhere = BizObject.ConvertNullToEmptyString(stringhere) and am getting the error edu.xxx.yyy.BLL.BizObject.ConvertNullToEmptyString(String) is inaccessible due to its protection level, where edu.xxx.yyy.BLL is the actual namespace of the class making the method call as well as, obviously, the namespace of the BizObject class.  I am making the same call from another class in the namespace and that call is working just fine, but it is not working in this instance.

Any help would be appreciated
Avatar of surajguptha
surajguptha
Flag of United States of America image

try changing protected to public
Avatar of larkydoo
larkydoo

ASKER

I went in and set the method to public static instead of protected static and it works now.  This is not a desirable solution, as it should have worked to begin with.  Would still like any insight into this anyone may have.
ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's it exactly.  Thanks!
If you are worried about its protection. try changing the modifer to internal which would only let access from all classes within the same assembly