i need a bit of help with my code if anyone is willing to help me. my code looks like this. button code ---
private void button6_Click(object sender, EventArgs e)
{ character tom = new character();
pictureBox1.Image = imageList1.Images[2];
tom.location = "Forest";
label10.Text = tom.location;
}
im trying to turn tom.locations value into Forest after the button press but after i used the debugger it showed me the tom.location is still the default value that i set. what am i doing wrong? tom
public int currenthp = 50;
public string name;
public bool whileCombat = true;
public int level = 1;
public int strength = 10;
public int gold = 0;
public int xp;
public int totallevel;
public int damage2;
public int potion = 3;
public int escape2;
public bool alive = true;
public string location = "";
First, You did't get a error when you debugged this code? I am not very sure of that, you can't call to tom.localitation , without a method of the Class Tom .
You can do a method of the class Tom , or declarare a static variable , I recommend you the static variable.
public static string localitation = "";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.