title: Dynamically creating Link Labels using foreach in c#
body: <p>I am trying to create link labels dynamically using foreach . I am setting the text of each linklabel to a string which is stored in flatestgames string array and whose links are stored in flatestlinks string array.
  But it is throwing a null reference exception at the line flg[i].Text = s though s is not set to null.
  Please help me out.
  Below is the code snippet:</p>
  
  <pre><code>if (!(flatestgames == null || flatestgames.Length &lt; 1))
          {
              i = 0;
              LinkLabel[] flg = new LinkLabel[10];
              foreach (string s in flatestgames)
              {
                  flg[i].Text = s;
                  flg[i].Links.Add(0, s.Length, flatestlinks[i]);
                  Point p = new Point(43, 200 + 23 * i);
                  flg[i].Location = p;
                  flg[i].Visible = true;
                  flg[i].Show();
                  this.Controls.Add(flg[i]);
                  i++;
              }
          }
  </code></pre>