title: C# Removing Last Element of a string Array?
body: <p>I am parsing a set of coordinates from an XML file. Each node will have coordinates like:</p>
  
  <pre><code>-82.5,34.1,0.000 -82.6,34.2,0.000
  </code></pre>
  
  <p>In the code below, the coords_raw variable is already assigned the above value and I am trying to split into array <code>lnglatset</code> --which does look okay.</p>
  
  <pre><code>    string[] lnglatset = raw_coords.Split(' ');//will yield like     [0]=-82.00,34.00,00000 // Will need to get rid of the last set of zeros
      foreach (string lnglat in lnglatset)
      {
         Console.WriteLine(lnglat);//-82.5,34.1,0.000; looks fine
      }  
  </code></pre>
  
  <p>From the above, the final value needed would be:                </p>
  
  <pre><code>     coords = "-82.5 34.1, -82.6 34.2";//note the space between lng/lat
  </code></pre>
  
  <p>But how do remove the junk values of 0.000 from each element of the array and put a space, instead of a comma between the lng and lat values in each element? I have tried some remove() function on <code>lnglat</code> but that was not allowed within the <code>foreach</code> loop. Thanks!</p>