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(s tring input)
{
return (input == null ? "" : input);
}
I am trying to call the method as stringhere = BizObject.ConvertNullToEmp tyString(s tringhere) and am getting the error edu.xxx.yyy.BLL.BizObject. ConvertNul lToEmptySt ring(Strin g) 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
protected static string ConvertNullToEmptyString(s
{
return (input == null ? "" : input);
}
I am trying to call the method as stringhere = BizObject.ConvertNullToEmp
Any help would be appreciated
try changing protected to public
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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