Vote count:
0
Want to use a variable based on its name. It is hard to describe. Here is the example
var sections = new [] {"Personnel", "General", "Medical"};
foreach (var s in sections)
{
// want to retrieve the variable "TableCellPersonnel"
(TableCell)Type.GetType(string.Format("TableCell{0}", s)).Text = "Test";
}
so that we don't have to :
TableCellPersonnel.Text="Test"
TableCellGeneral.Text="Test"
TableCellMedical.Text="Test"
So, is it possible for this kind of "reflection"?
asked 2 mins ago
Aucun commentaire:
Enregistrer un commentaire