title: C# trim string returned from function
body: <p>I'm trying to trim the end of a string of variable length returned from a function.</p>
  
  <p>The function returns a string formatted like:
      PC Type + "\t\t" + MACAddress + "\t\t" + NumPC + "\t\t" + Date</p>
  
  <p>eg:</p>
  
  <blockquote>
    <p>Server      00:11:22:33:44:55      124     06-12-13</p>
    
    <p>PC          AA:BB:CC:DD:EE:FF      16      01-01-12</p>
  </blockquote>
  
  <p>I am attempting to remove the part of the string after the MAC address, I have tried using the below method but don't seem to be having much luck.</p>
  
  <pre><code>int index = Licences.LastIndexOf(":");
  if (index &gt; 0)
  Licences = Licences.Substring(0, index + 2);
  </code></pre>
  
  <p>Is there an elegant way to do this?</p>