LabelBouncer[] bouncers = new LabelBouncer[3]; // Creating array with 3 objects. private void ToggleBouncing(int index, Label labelToBounce) { if (bouncers[index] == null) // if reference == null, create object. { bouncers[index] = new LabelBouncer(); bouncers[index].MyLabel = labelToBounce; } else { bouncers[index] = null; } }
private void ToggleBouncing(int index, Label labelToBounce) { if (bouncers[index] == null) { bouncers[index] = new LabelBouncer(); bouncers[index].MyLabel = labelToBounce; } else { bouncers[index] = null; } }