C # Really does not support this type of syntax.
Put labels in some structure and use it to manage labels. Here are some examples:
List<Label> labels = new List<Label>();
int i =
labels[i].visible = true;
Dictionary<string, Label> labelDict = new Dictionary<string, Label>();
labelDict.add("label1", label1);
labelDict["label1"].visible = true;
Alternatively, you can get shortcuts from the list of parent forms of child controls and set the visibility this way.
source
share