c# .net

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

How to Remove the last char of String in C#? , someone asked me to explain?

 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

Post your comments / questions