ASP.Net C# TrimEnd String Function

by top54u.com 07 Jul, 2008

In ASP.Net, C# TrimEnd String Function enables you to remove the unwanted or special characters at the end of the specified string. C# TrimEnd String Function takes one parameter of Char [ ] array type. You can pass the array of special characters to the TrimEnd function to remove the specified characters from the end of the string. It traverse the string from its right end i.e. start point from its character at last index and removes the special characters specified in the char [ ] array.

 

Example of ASP.Net C# TrimStart string Function

 

string strText = "\":ASP.Net \"C#\" TrimEnd Function:\"";

char[] specialChars = new char[] { '"', ':' };

Response.Write(strText + "<br />");

Response.Write(strText.TrimEnd(specialChars) + "<br />");

 

Output:

":ASP.Net "C#" TrimEnd Function:"

 

":ASP.Net "C#" TrimEnd Function

 

 

In the above example of ASP.Net C# TrimEnd string function, two outputs show the original string and trimmed string. Second string has been retrieved without any special character at the end coz C# TrimEnd string function removed the chars specified in the char [ ] array. But special Chars at the beginning of the string are not removed coz TrimEnd function removes the special chars only from the end that’s why starting and in between string special chars are not being removed. You can use the ASP.Net C# TrimStart string function to remove the special chars at the beginning of the specified string.

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , , , , , , , ,

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:41:19 AM




related videos.....
recent posts.....
top54u ezines.....