So I decided to learn C# a few hours ago and ran into some problems.
I want it to save the state of the checkboxes in the dialog shown in the pictures below. So when I open the dialog up again (without closing Main before) it should remember the exact same states.
In addition, I'm having some troubles getting an Int from the dialog to main. I want main to be able to see Bitmask and know the value of it.
I might be using some wrong terms, my coding might be shitty, but keep in mind that I have only been playing around with C# for like 2 hours and this is the second program I'm making.
I want it to save the state of the checkboxes in the dialog shown in the pictures below. So when I open the dialog up again (without closing Main before) it should remember the exact same states.
In addition, I'm having some troubles getting an Int from the dialog to main. I want main to be able to see Bitmask and know the value of it.
Code:
public int Bitmask { get; set; }
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
Bitmask += 1;
if (checkBox2.Checked)
Bitmask += 4;
if (checkBox3.Checked)
Bitmask += 8;
if (checkBox4.Checked)
Bitmask += 64;
if (checkBox5.Checked)
Bitmask += 1024;
if (checkBox6.Checked)
Bitmask += 2;
if (checkBox6.Checked)
Bitmask += 16;
if (checkBox6.Checked)
Bitmask += 32;
if (checkBox6.Checked)
Bitmask += 128;
if (checkBox6.Checked)
Bitmask += 512;
this.Close();
}
I might be using some wrong terms, my coding might be shitty, but keep in mind that I have only been playing around with C# for like 2 hours and this is the second program I'm making.
Last edited: