I have taken a simple interface
public interface IBinaryHelper
{
toBinary ConvertToBinary(string pathBinary);
}
I am trying access is in a class below it
public class ApiHelper : IBinaryHelper
{
private readonly RestClient _client;
public toBinary ConvertToBinary(string pathBinary)
{
toBinary binary = null;
var request = new RestRequest("SampleAPI/ConvertToBinary/{pathBinary}", Method.GET) { RequestFormat = DataFormat.Json };
request.AddParameter("pathBinary", pathBinary, ParameterType.UrlSegment);
var response = _client.Execute<toBinary>(request);
binary = response.Data;
return binary;
}
}
Now when build it, this is the error am getting an error Inconsisten accessibility:
Return type
ApiHelper.toBinary
is less accessible than methodApiHelper.ApiHelper.ConvertToBinary(string)
atConvertToBinary
method both in interface and in the class
You are returning an object of type toBinary
from a public method on a public class.
The toBinary
class needs to be visible to all possible callers of the ApiHelper.ConvertToBinary
method - therefore, it should be public as well.
As the error says, the inconsistency is not by calling that method, but toBinary
is apparently a class that is not public
. You cannot offer a method as public
, if one cannot access the return type publicly.
Apparently your toBinary
class
/ interface
/ struct
/... is internal
, private
, inner class,... You should make this public as well.
Another hint: the names of classes start in general with an uppercase character. So it should be ToBinary
not toBinary
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.