Reputation: 31
I want to change the global integer- amount, by make his value as 'c' value, how can i do that?
public static class Globals
{
public const int amount = 5689;
}
private void button1_Click(object sender, EventArgs e)
{
int b = int.Parse(textBox2.Text);
int c = Globals.amount - b;
textBox3.Text = c.ToString();
**Globals.amount = c;** // ***how do i set this?***
}
Upvotes: 0
Views: 199
Reputation: 1026
Since amount is defined as a constant, you can't change it.
You can, however change it if you made it a non-constant static variable instead.
public static int amount = 5689;
Upvotes: 1