Advertisement
Guest User

Untitled

a guest
May 4th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public partial class Form1 : Form
  2. {
  3. Label[,] labelki = new Label[4, 4];
  4. Random los = new Random();
  5. Label wylosowanyLabel = null;
  6.  
  7. public Form1()
  8. {
  9. InitializeComponent();
  10. }
  11.  
  12. private void ZmienKolor()
  13. {
  14. int i = los.Next(1, 4);
  15. int j = los.Next(1, 4);
  16. wylosowanyLabel = labelki[i, j];
  17. wylosowanyLabel.BackColor = Color.Red; //I get a NullReferenceException here
  18. }
  19.  
  20. private void btnStart_Click(object sender, EventArgs e)
  21. {
  22. timer1.Start();
  23. ZmienKolor();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement