I was writing a C# Forms document in Express 2012 and came up with an unusual bug. I have some random data I'm displaying in dataform grid that I'm retrieving from an array of classes. If I run the program, the data grid (and the actual array of classes) are all copies of whats stored in array[0]. If I use the debugger and step through the entire process, the variables all contain different data and the datagrid displays this data correctly. Any ideas why that would be the case? Here is some code snippets if that helps at all:
I added 2 classes one called Player, and one called Game. Game contains the following code:
Code:
public class Game
{
public Player[] player = new Player[16];
public Game()
{
int i;
for (i = 0; i <player.Length; i++)
{
player[i] = new Player();
}
}
}
Now my in the Form Document i added this:
Code:
public partial class Form1 : Form
{
public Game myGame = new Game();
public Form1()
{
InitializeComponent();
}
The final thing is the Player class has a function called Initialize player.. it is just a bunch of code using Random to make up some various stats, which i run from the Form1_Load
Code:
for (i = 0; i < myGame.player.Length; i++)
{
myGame.player[i].InitializePlayer();
}
AGain if i just run the program myGame.player[0] gets randomized and then 1=15 are just copeis of it. But if i step through it, they are all unique.?!? is this some crazy bug in VSE 2012?