C# , Substring How to access last elements of an array/string using substring
<p>I am generating 35 strings which have the names <code>ar15220110910, khwm20110910</code> and so on. </p>

<p>The string contains the name of the Id <code>(ar152,KHWM)</code>, and the date <code>(20110910)</code>. I want to extract the <code>Id, date</code> from the string and store it in a textfile called <code>StatSummary</code>.</p>

<p>My code statement is something like this</p>

<pre><code>for( int 1= 0;i&lt; filestoextract.count;1++)
{
    // The filestoextract contains 35 strings
    string extractname = filestoextract(i).ToString();  
    statSummary.writeline( extractname.substring(0,5) + "" + 
         extractname.substring(5,4) + "" + extractname.substring(9,2) + "" + 
         extractname.substring(11,2));
}
</code></pre>

<p>When the station has Id containing 5 letters, then this code executes correctly but when the station Id is <code>KHWM</code> or any other 4 letter name then the insertion is all messed up. I am running this inside a loop. So I have tried keeping the code as dynamic as possible. Could anyone help me to find a way without hardcoding it. For instance accessing the last 8 elements to get the date??? I have searched but am not able to find a way to do that.</p>
