I am selecting data from database and in while loop, i want it store all data in one variable. How to do that?
The variable selectAnswer is string array type .
I used this code but this give error. Modify this code.
string selectAnswer[] = new string[];
while (rdr.Read())
{
selectAnswer[] = rdr[0].ToString();
}
Your question is quite confusing.
You want to store the data into a single variable or into a single string?
If that’s the case why not use a StringBuilder instead.
But I’m still not sure if I undestood correctly.
Other option is using a list: