So, what I am trying to do is iterate through an array of x values, and for each iteration, get the current text value of label “plabel” + x (the labels are all already created and named. I am relatively new to using reflection, but from what I’ve read the following should work:
PropertyInfo pI;
pI = this.GetType().GetProperty("plabel" + count + ".Text"); //count is the current iteration #
MessageBox.Show(pI.Name);
But this is throwing a runtime exception. Can somebody please show me the correct way of doing this?
Try something like this: