日期:2014-05-18  浏览次数:20730 次

大家帮帮看下,这么写合适嘛?
类2 继承 类1 
类1种定义好多属性, 窗体2中的文本框获取的值,都保存到类1的属性里面

代码:
public class edbData : System.Windows.Forms.Form
{
  private static string key1;
  public static string Key1
  {
  set
  {
  key1 = value;
  }
  get
  {
  return key1 == null ? "" : key1;
  }
  }
}
public class PosCommonData :edbData
{
  。。。。。
}
wfp_edbposwork : PosCommonData
{
  把界面的值赋值给Key1
}


请问大家有这样写代码的啊? 这样写有什么好处啊?

------解决方案--------------------
类1的写法是很正规的方式,实现了对相关数据的封装。

类2没看明白,为什么需要它?