C# - Remove Last Character from String in VB.NET


C# - Remove Last Character from String in VB.NET

Mar 13, 2013
Introduction: 

Here I will explain how to remove last character from string in 
c#vb.net using asp.net.
Description
  
In previous posts I explained 
jQuery Remove first or last characters from stringDelete selected rows from datatable in c#, vb.netjQuery get number of facebook likes, shares, comments count for url and many articles relating to Asp.netGridviewAjaxJQuery. Now I will explain how to remove last character from string in c#vb.net using asp.net.

To implement this functionality we have different methods 

Method 1 in C#

protected void Page_Load(object sender, EventArgs e)
{
string istr = "1,2,3,4,5,6,7,8,9,10,";
string ostr = istr.Remove(istr.Length - 1, 1);
Response.Write(ostr);
}
Method 1 in VB.NET


Protected Sub Page_Load(ByVal sender As ObjectByVal e As EventArgs) Handles Me.Load
Dim istr As String = "1,2,3,4,5,6,7,8,9,10,"
Dim ostr As String = istr.Remove(istr.Length - 1, 1)
Response.Write(ostr)
End Sub
Method 2 in C#


protected void Page_Load(object sender, EventArgs e)
{
string istr = "1,2,3,4,5,6,7,8,9,10,";
string ostr = istr.Trim(",".ToCharArray());
Response.Write(ostr);
}
Method 2 in VB.NET


Protected Sub Page_Load(ByVal sender As ObjectByVal e As EventArgs) Handles Me.Load
Dim istr As String = "1,2,3,4,5,6,7,8,9,10,"
Dim ostr As String = istr.Trim(",".ToCharArray())
Response.Write(ostr)
End Sub

Comments