- 1,2,3,4,5
Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Remove the last character from a string
From Wiki
Summary: Remove the last character from a string
There may be times when you have built up a delimited string of character or words, and then needed to remove the last character/delimiter from the end of the string.
Here's a simple function that you can just pass your string to and it will return the string with the last character removed:
- Imports System.Text.RegularExpressions
- Partial Class Default1
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Response.Write(RemoveLastCharacter("1,2,3,4,5,"))
- End Sub
- Private Function RemoveLastCharacter(ByVal Text As String) As String
- Return Text.Substring(0, Text.Length - 1)
- End Function
- End Class
Output:
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.