-4

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;
 }
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sweta Priya
  • 183
  • 2
  • 2
  • 7

1 Answers1

6

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

List<string> elements = new List<string>();
foreach(xmlnode anode in somecollection)
{
  elements.Add("string");
}
Community
  • 1
  • 1
David Starkey
  • 1,840
  • 3
  • 32
  • 48