protected void Button_Clicked(object sender, EventArgs e) { string tostring = ""; if (sender.GetType() == typeof(ButtonBuilding)) { ButtonBuilding B = sender as ButtonBuilding; tostring = B.Building.ToString(); } else if (sender.GetType() == typeof(ButtonUnit)) { ButtonUnit B = sender as ButtonUnit; tostring = B.Unit.ToString(); } Console.WriteLine(tostring); Program.UI.txtUnitInfo.Text = tostring; }
void button_Click(object sender, System.EventArgs e) { ButtonUnit butt = sender as ButtonUnit; Program.UI.txtUnitInfo.Text = butt.Unit.ToString(); }