我一直在嘗試一些n層架構,我真的想知道爲什麼這段代碼不會編譯...爲什麼不能公開一個實現的接口方法?
它說修飾符公共不適用於這個項目。但爲什麼不呢?我需要能夠從BLL對象訪問項目IRepository.AddString(),但它只是不會讓我把它公開....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
BLL myBLL = new BLL();
}
}
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();
}
}
}