I have a class of string constants, how can I loop through to get the string and populate a list-box?
static class Fields
{
static readonly string FirstName = "FirstName";
static readonly string LastName = "LastName";
static readonly string Grade = "Grade";
static readonly string StudentID1 = "StudentID";
static readonly string StudentID2 = "SASINumber";
}
public partial class SchoolSelect : Form
{
public SchoolSelect()
{
InitializeComponent();
//SNIP
// populate fields
//Fields myFields = new Fields(); // <-- Cant do this
i = 0;
foreach (string field in Fields) // ???
{
fieldsBox.Items.Insert(i, Fields ???
}
}
I can't create a new instance of Fields because its a static class. How can I get all the fields into the list-box without manually inserting each one?