using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace GuyCash { public partial class Form1 : Form { Guy joe; Guy bob; int bank = 100; public Form1() { InitializeComponent(); joe = new Guy(); joe.Name = "Joe"; joe.Cash = 50; } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (bank >= 10) { bank -= joe.ReceiveCash(10); UpdateForm(); } else { MessageBox.Show("В банке нет денег"); } } private void button2_Click(object sender, EventArgs e) { bank += bob.GiveCash(5); UpdateForm(); } } public void UpdateForm () { joesCashLabel.Text = joe.Name + "имеет $" + joe.Cash; bobsCashLabel.Text = bob.Name + "имеет $" + bob.Cash; bankCashLabel.Text = "В банке сейчас $" + bank; } } Class Guy works for me separately, without jambs. I decided to bind it to the Button and Label interface.
The UpdateForm method is responsible for Label, which persistently complains about void and does not want to work. The error comes out in the form: Expected class, delegate, enum, interface, or struct. I checked that there were no errors (but unfortunately I do not know how to use the debtor in full measure). Program started a few days ago. Help me please. Thanks for attention.
UpdateForminside the class, you have this method fell outside the curly brackets of the class. - Athari