title: Using right and left string functions inside c#
body: <p>I've written a cs page called Global Validation.  It looks like this:</p>
  
  <pre><code>using System;
  using System.Configuration;
  using System.Data.SqlClient;
  using System.Data;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Drawing;
  using System.Web.UI.WebControls;
  
  
  namespace ClientDPL
  {
  
    public static class StringExtensions
    {
      public static string Right(this string str, int length)
      //Usage: 
      //  string ActiveUser = System.Web.HttpContext.Current.User.Identity.Name;
      //  string LoginID = ActiveUser.Right(6);
      {
          return str.Substring(str.Length - length, length);
      }
  
      public static string Left(this string str, int length)
      //Usage: 
      //  string ActiveUser = System.Web.HttpContext.Current.User.Identity.Name;
      //  string LoginID = ActiveUser.Left(6);
      {
          return str.Substring(0, length);
      }
    }
  }
  </code></pre>
  
  <p>When I try to use the Left function on a cs page of one of my web pages to get the first 6 characters of a string, like this:</p>
  
  <pre><code>string MyOtherString = "Hello World!";
  string MyString = MyOtherString.Left(6);
  </code></pre>
  
  <p>I'm getting an error:</p>
  
  <blockquote>
    <p>String does not contain a definition of 'Left', and no extension<br>
    method of 'Left' accepting a first argument of type 'string' could be found.</p>
  </blockquote>
  
  <p>I am 100% positive I've used this before, the functions were cannibalized from another project, but I'm just wondering if maybe I somehow needed to hook it into the app somewhere?  There's got to be a step I missed in making these functions usable throughout the application.</p>