通用接口中的属性

时间:2012-04-05 16:20:55

标签: c# properties interface

我有两组属性是共同的。我想将它们移到界面中。由于这些属性都是get和set,我不确定是否允许我从另一个类中设置它们。我在类中实现了我需要这些属性的接口,但我仍然无法访问这些属性。我的课程如下:

public class PatchSurveyStartegy : IStrategy
{
  public IEnumerable<IEnumerable<PointBase>> ReceiverGrid { get; set; }

  public IEnumerable<IEnumerable<PointBase>> SourceGrid { get; set; }

  public SourceParameters SourceParameters { get; set;}

  public DeploymentParameters DeploymentParameters { get; set; }

  public RovParameters RovParameters { get; set; }
}

所以,IStrategy是我想要移动所有这些属性的接口,但我在这个类中无法访问它们:

internal double DeployRemainingLines()
  {
     return StepsForGivenLines(ReceiverGrid).Sum(step => step.CalculateStepTime());
  }

我查看了以下链接:Interface should not have properties?c# properties on Interface。另外,我不想把它们放在一个抽象类中,我想使用一个接口。

0 个答案:

没有答案