c# - Store each value of a 'foreach' loop into a string array -


consider:

 string[] collection = new string[3]{"hi","hello","test"};   string [] elements = new string [3];  int index = 0;  foreach(string anode in collection)  {    string[index++] = anode;  } 

https://stackoverflow.com/a/599373/1618257:

list<string> elements = new list<string>(); foreach(xmlnode anode in somecollection) {   elements.add("string"); } 

Comments