public partial class Form1 : Form { public Form1() { InitializeComponent(); } public class class1 { private string con; public string? CON { get { return this.con; } set { this.con = value; } } } private class1 test = null; private void button1_Click(object sender, EventArgs e) { if (this.test == null) { this.test = new class1(); this.test.CON = "2"; } } private void button2_Click(object sender, EventArgs e) { if (this.test == null) { MessageBox.Show("まだ初期化されていません"); } else { string value = this.test.CON; } } }