问题描述:
public class a:Form
{
   public DateTime startdate;
   pubiic DateTime enddate;
   public a
   {
   }
   private void   Button1_Click(object sender,EventArgs e)
   {
       b f1=new b();
       f1.type=typeof(a);
       f1.Owner=this;
       f1.Show();
   }   
}
public class b:Form
{
  Public Type type;
  Public b()
  {
  }
  
  private void Button1_click(object sender,EventArgs e)
  {
    ((type)this.Owner).startdate=...;//出错的地方
    ((type)this.Owner).enddate=....;//出错的地方
  }
}运行时会出现错误:b.type表示字段,此处就为类
各位老大,请问如何解决!!

解决方案 »

  1.   

    private void Button1_click(object sender,EventArgs e)
      {
        ((type)this.Owner).startdate=...;//出错的地方
        ((type)this.Owner).enddate=....;//出错的地方
      }
    ==============================>
      private void Button1_click(object sender,EventArgs e)
      {
        object oa = this.Owner;
        a aform; 
        if( aform as a != null )
        {
            aform .startdate=...;//出错的地方
            aform .enddate=....;//出错的地方
      }
      

  2.   

    sorry ,写错了private void Button1_click(object sender,EventArgs e)
      {
        
         
        a aform = this.Owner as a 
        if( aform != null )
         {
            aform .startdate=...;//出错的地方
            aform .enddate=....;//出错的地方
         }
      }
      

  3.   

    ((Type)this.Owner).startdate=...;//出错的地方
      

  4.   

    是要反射吧
    using System.Reflection;
    ...
    //出错的地方
    FieldInfo myFieldInfo1 = type1.GetField("startdate", BindingFlags.Public | BindingFlags.Instance);
    myFieldInfo1.SetValue(this.Owner,"起始日期");