Method Inaccessible due to its protection level

Posted on 2007-10-09
Medium Priority
Last Modified: 2008-02-01
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
Question by:larkydoo
  • 3
  • 2
LVL 21

Expert Comment

ID: 20042287
try changing protected to public

Author Comment

ID: 20042298
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.
LVL 21

Accepted Solution

surajguptha earned 2000 total points
ID: 20042321
The protected keyword is a member access modifier. A protected member is accessible within its class and by derived classes.

The class from which it worked when you had its access modifier as Protected, is that class derived from the BizObject??

Author Comment

ID: 20042342
That's it exactly.  Thanks!
LVL 21

Expert Comment

ID: 20042344
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question