Reply to topic
ASP.NET Functions
eriweb


Joined: 06 Apr 2004
Posts: 68
Reply with quote
Hello all,

I am tring to find a function similar to the Left and Right string manipulation functions in asp.net c#. Can any one please help with this. Thank you in advance.
bobum
Elvis Fanatic
Elvis Fanatic

Joined: 16 Nov 2004
Posts: 746
Location: Montgomery, AL
Reply with quote
Try this on for size...

Code:

public static class LeftRightMid
{
   public static string Left(string param, int length)
   {
      //we start at 0 since we want to get the characters starting from the
      //left and with the specified lenght and assign it to a variable
      string result = param.Substring(0, length);
      
      return result;
   }
   
   public static string Right(string param, int length)
   {
      //start at the index based on the lenght of the sting minus
      //the specified lenght and assign it a variable
      string result = param.Substring(param.Length - length, length);
      
      return result;
   }

   public static string Mid(string param,int startIndex, int length)
   {
      //start at the specified index in the string ang get N number of
      //characters depending on the lenght and assign it to a variable
      string result = param.Substring(startIndex, length);
      
      return result;
   }
}
eriweb


Joined: 06 Apr 2004
Posts: 68
Reply with quote
Thanks Bobum, that's exactly what I was looking for.
ASP.NET Functions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic