How do I write this loop as a single line?
c#, c#-4.0, dataset, for-loop, linq
Solution
I think it could.
lstAllMonsters = dsAllMonsters.Tables[0].Rows
.Cast<DataRow>()
.Select(r => r["pokemonId"].ToString())
.ToList();
Problem
I don't know this is possible or not but let me ask you. How do I write the below loop in a shorter way using, for example, LINQ? ``` DataSet dsAllMonsters List<string> lstAllMonsters for (int i = 0; i < dsAllMonsters.Tables[0].Rows.Count; i++) { lstAllMonsters.Add(dsAllMonsters.Tables[0].Rows[i]["pokemonId"].ToString()); } ```