-2

我不确定它在C#.

我有一堂课:

public class FindIt()
{
}

public class FindItFrm()
{
  private bool _amISet = false; 

  public FindItFrm()
  {
  }

  public bool AmISet()
  {
      get { return _amISet; }
  set { _amISet = value; }
  }
}

我正在学习的课程有:

public class MyHelper() : FindIt
{
    // Constructor
           public MyHelper()
            : base(new FindItFrm())
}

我想在类内的 while中设置一个属性( AmISet)。我将如何做到这一点?FindItFrmMyHelper

4

1 回答 1

0

您的代码应如下所示(将来,请发布工作代码作为示例):

public class FindIt
{
    // You need to let your derived class access the FindItFrm
    protected FindItFrm Frm;

    // Constructor needs to accept a FindItFrm
    public FindIt(FindItFrm frm)
    {
        Frm = frm;
    }
}

public class FindItFrm
{
    private bool _amISet = false; 

    public bool AmISet
    {
        get { return _amISet; }
        set { _amISet = value; }
    }
}

public class MyHelper : FindIt
{
    // Constructor
    public MyHelper()
        : base(new FindItFrm())
    {
        Frm.AmISet = true;
    }
}
于 2013-01-30T18:50:14.563 回答