I have a small problem with MySqlDataReader. I have data in MySql and I have column "name" and X rows under. Reader reads sucessfully all of this but output is in one string and looks like "FirtSecondThird" but i need all of this words in list word by word. The code is:
while (reader.Read())
{
vystup.Add(reader[0].ToString());
}
connection.Close();
string out1 = "";
foreach (string outage in vystup)
{
out1 = outage "\n";
}
return out1;
Does anyone know what to do with it? Thanks.
CodePudding user response:
You can use String.Join
if vystup
is a List<string>
which contains the following items
"first", "second","third"
then
outputting string.join(Enviorment.NewLine, vystup)
will yield
"first"
"second"
"third"