title: Create objects within a foreach to push to an array in C#
body: <p>What I am trying to achieve is to split a string into multiple adresses like "NL,VENLO,5928PN" which getLocation will return a "POINT( x y)" string value.</p>
  
  <p>This works. Next I need to create a WayPointDesc object for each location. And each of these objects has to be pushed into the WayPointDesc[]. I have tried various methods but I cannot find a feasable option so far. My last resort is to hardcode a maximum amount of waypoints but I would rather avoid such a thing.</p>
  
  <p>Using a list is unfortunately not an option... I think.</p>
  
  <p>This is the function:</p>
  
  <pre><code>    /* tour()
       * Input: string route
       * Output: string[] [0] DISTANCE [1] TIME [2] MAP
       * Edited 21/12/12 - Davide Nguyen
       */
      public string[] tour(string route)
      {
          // EXAMPLE INPUT FROM QUERY
          route = "NL,HELMOND,5709EM+NL,BREDA,8249EN+NL,VENLO,5928PN"; 
          string[] waypoints = route.Split('+');
  
          // Do something completly incomprehensible
          foreach (string point in waypoints)
          {
              xRoute.WaypointDesc wpdStart = new xRoute.WaypointDesc();
              wpdStart.wrappedCoords = new xRoute.Point[] { new xRoute.Point() };
              wpdStart.wrappedCoords[0].wkt = getLocation(point);
          }
  
          // Put the strange result in here somehow
          xRoute.WaypointDesc[] waypointDesc = new xRoute.WaypointDesc[] { wpdStart };
  
          // Calculate the route information
          xRoute.Route route = calculateRoute(waypointDesc);
          // Generate the map, travel distance and travel time using the route information
          string[] result = createMap(route);
          // Return the result
          return result;
  
          //WEEKEND?
      }
  </code></pre>