How to Remove Last Character from string in Dot Net.

vishalneeraj-24503
Posted by vishalneeraj-24503 under VB.NET category on | Points: 40 | Views : 1249
There are several ways to Remove Last Character from string in Dot Net:-

Let's take an example:-

Dim str1 As String = "A,B,C,D,E," //Original string
//I want to remove last character i.e. "," from string str1

1). Dim str2 As String = str1.TrimEnd(",")
2). Dim str3 As String = str1.Substring(0, str1.LastIndexOf(","))
3). Dim str4 As String = str1.Remove(str1.Length - 1)

Output will be:-
1). A,B,C,D,E
2). A,B,C,D,E
3). A,B,C,D,E

Comments or Responses

Login to post response