C# 4.0 Ilist和Iqueryable

C# 4.0 Ilist和Iqueryable,c#-4.0,C# 4.0,这是我在应用程序中使用的代码,但我对这里需要一个ilist接口和使用iqueryable感到困惑。它们的确切定义是什么 private IList<Emp2> getcountry() { IList<Emp2> countryList = null; using (CountryDataContext context = new CountryDataContext(ConnectionString))

这是我在应用程序中使用的代码,但我对这里需要一个ilist接口和使用iqueryable感到困惑。它们的确切定义是什么

private IList<Emp2> getcountry()
        {
            IList<Emp2> countryList = null;
            using (CountryDataContext context = new CountryDataContext(ConnectionString))
            {
              IQueryable<Emp2> query = from c in context.Emp where c.EmpName=="ss"select c;
                countryList = query.ToList();
            }

            return countryList;
        }
private IList getcountry()
{
IList countryList=null;
使用(CountryDataContext上下文=新的CountryDataContext(ConnectionString))
{
IQueryable query=来自context.Emp中的c,其中c.EmpName==“ss”选择c;
countryList=query.ToList();
}
返回国家列表;
}

它们都是接口

C#中的接口:

msdn链接:


我的意思是什么是ilist和iqueryable??在询问这里之前,您是否费心搜索?有关MSDN的文档非常丰富。谢谢,先生。我知道两者都是接口,但我们如何使用ilist作为方法签名。。何时使用此ilist和iqueryable接口?您可以将其用作签名,以便可以从所述接口返回实现的类/结构。它有助于将代码与实现解耦。您可以有许多从IList实现的类,并将它们中的任何一个用作返回类型。在.Net中,编程到一个接口是典型的好编程,这样代码就不那么死板了。由于不小心使用了MSDN链接的副本而不是CodeProject链接到接口教程,所以编辑了我的原始帖子。