0
파생 클래스에서 기본 클래스의 필드 값을 변경할 수 있는지 질문이 있습니다. 내 경우, 나는 창문이 두 클래스 클래스를 가지고 RichTextBox
형태로, 그리고 난 RichTextBox
지우기 클래스를 파생 사용 싶습니다.파생 클래스에서 기본 클래스 필드 값 변경
초기화 RichTextBox
:
this.rtfCode.Location = new System.Drawing.Point(45, 26);
this.rtfCode.Name = "rtfCode";
this.rtfCode.ShowSelectionMargin = true;
this.rtfCode.Size = new System.Drawing.Size(100, 96);
this.rtfCode.TabIndex = 1;
this.rtfCode.Text = "some text";
기본 클래스 :
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine(this.rtfCode.Text);
DerivedClass f = new DerivedClass();
Console.WriteLine(f.rtfCode.Text);
}
}
내 파생 클래스
class DerivedClass:Program
{
public DerivedClass()
{
base.rtfCode.Clear();
}
}
을 내가 프로그램을 실행하고 button
RichTextBox
에 난 아직 텍스트를 보려면 누릅니다.