c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to Remove the last char of String in C#?

| | CSharp

 Remove last character from string using c#. If we want to remove the last char of my string whatever it is. So we want if my string is "12342" became "1234". 


 


var input = "12342";
var output = input.Substring(0, input.Length - 1);

or

var output = input.Remove(input.Length - 1); 

output:


 1234