Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Not sure if this is all of your code, but there are a lot of things you can do. One thing is that the class you posted is static, so to refer to the fields in it you would need to do something like Mech_CommonFields.NUMBER_OF_EQUIPABLE_SECTIONS. For static classes, you simply use the class name followed by the field (property, method, etc). Not sure why you're using constants though, as I would expect those values to change between different mechs (never played the game, so don't know for sure). Commented Mar 28, 2013 at 5:25
  • You've declared the fields as constants, so you can't assign new values to them, you can only read the values. Commented Mar 28, 2013 at 5:26
  • @Tim sorry tim, you are right, but i know using static varibles it will work. I am also working on the same situation where i have to varibles from another .cs file. Commented Mar 28, 2013 at 5:32
  • @Freelancer - No problem. Yes, static variables will work - but it's important to note that may not be the best way to do things in this case, as there will be only one instance for each of those variables no matter how many mechs there are - change it for one mech, you change it for all. Commented Mar 28, 2013 at 5:33
  • If your loadMech() method is in a different class then Mechs, you will need to create an instance of the class to access the fields, like this Mechs myMech = new Mechs(); - then you can do txtMechChassis.Text = myMech.mechChasis;, for example. Commented Mar 28, 2013 at 18:42