110,502
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
public class BaseForm : Form
{
public BaseForm()
{
this.Name = "baseform";
}
public virtual string FormName
{
get
{
return this.Name; ;
}
set
{
this.Name = value;
}
}
}
public partial class Form1 : BaseForm
{
public Form1()
{
InitializeComponent();
this.Name = "Form1";
MessageBox.Show(FormName);
}
public override string FormName
{
get { return this.Name; }
set { this.Name = value; }
}
}
}
baseform:
public virtual string Name
{
get
{
return this.Name;;
}
set
{
this.Name = value;
}
}
mainform:
public override string Name
{
get { return this.Name; }
set { this.Name = value; }
}
//在你的mainForm中重写
public override string Name
{
get{return this.id.tostring();}
set{this.id=Convert.Toint32(value);}
}