简体   繁体   English

使用列表实现接口并获取值c#

[英]Implement Interface with List and get Value c#

I have an interface named IConnector 我有一个名为IConnector的接口

Which has the following properties: 具有以下属性:

[OperationContract]
List<Details> RequestDetailsSchedule();

[OperationContract]
bool SetDetailsSchedule(List<Details> lstDetails);

I tried Implementing by 我尝试实施

public class Regulator: IConnector
public List<Details>RequestDetailsSchedule
{
  throw new NotImplementedException();
}

How do i get the contents of the list? 我如何获得清单的内容?

This is the most basic way to implement to interface. 这是实现接口的最基本方法。

public class Regulator: IConnector
{
    public List<Details> RequestDetailsSchedule()
    {
        throw new NotImplementedException();
    }
    public bool SetDetailsSchedule(List<Details> lstDetails)
    {
        throw new NotImplementedException();
    }
}

Where does the list come from? 清单来自哪里? A database? 数据库? Anyway, just 'cause you're putting up an abstraction, I'd do it all the way, like this: 无论如何,只是因为您要提出一个抽象,所以我会一直这样做,就像这样:

public interface IConnector {
    IEnumerable<Details> RequestDetailsSchedule();
    bool SetDetailsSchedule(IEnumerable<Details> details);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM