Possible Duplicate:
Why Explicit Implementation of a Interface can not be public?
I read this Question. Straight from the question
interface IRepository<T>
{
void AddString();
}
interface IStringRepo : IRepository<string>
{
List<string> GetStrings();
}
public class BLL : IStringRepo
{
public List<string> FilterStrings()
{
return new List<string>() { "Hello", "World" };
}
public List<string> IStringRepo.GetStrings()
{
throw new NotImplementedException();
}
public void IRepository<string>.AddString()
{
throw new NotImplementedException();
}
}
Why does making an explicitly referenced member public is an Error?
This is by design, just imagine one of the most popular reasons which forces a developer to implement an interface explicitly: memeber name ambiguity, so you have an existing class which already exposes public member with some name, and you can’t change an existing class API since it is used by other systems also you cannot change interface API (member names/signatures), and both class and interface defines a member with the same name, so providing
publicacces modifier for an interface member does not make sense since member with the same name already declared in a class.MSDN, 13.4.1 Explicit interface member implementations