Please consider X which is an object array. Say object[10]. Elements of the object array represent different values, for e.g. object[1] is studentname, object[2] is birthdate, object[3] is address, and so on.
Following is the way I am trying to pull those values into corresponding variables which I need for further processing
string studentName;
string birthDate;
string address;
IEnumerable<object> collection = (IEnumerable<object>)X;
int counter = 0;
foreach (object obj in collection)
{
if (counter == 0)
studentName = obj.ToString();
if (counter == 1)
birthDate = obj.ToString();
if (counter == 2)
address = obj.ToString();
...
counter++;
}
Is this the correct way to get the values of object array into individual variables? Something doesn't feel right.
Thanks