Récupérer les éléments de List<string>[]
Bonjour à tous,
J'ai une classe DBconnect avec cette fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public List<string>[] SelectLogin()
{
string query = "SELECT usernameLogin, passwordLogin FROM login";
List<string>[] list = new List<string>[2];
list[0] = new List<string>();
list[1] = new List<string>();
if (this.OpenConnection() == true)
{
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
list[0].Add(dataReader["usernameLogin"] + "");
list[1].Add(dataReader["passwordLogin"] + "");
}
dataReader.Close();
this.CloseConnection();
return list;
}
else
{
return list;
}
} |
Je récupère les éléments de cette façon :
Code:
1 2
| DBConnect db = new DBConnect();
List<string>[] login = db.SelectLogin(); |
Comment pourrais-je afficher le username et password?
Si j'essaye avec un foreach, une erreur s'affiche en disant
Impossible de convertir le type 'System.Collections.Generic.List<string>' en 'string'.
Merci d'avance pour votre réponse :D