How to remove the last character from a string in C#

1 Answer

0 votes
using System;
 
public class RemoveTheLastCharacterFromAString_CShatp
{
    public static void Main()
    {
        string s = "abcdfg*";
 
        s = s.Remove(s.Length - 1, 1);
 
        Console.WriteLine(s);
    }
}
 
 
  
/*
run:
      
abcdfg
  
*/

 



answered Jan 20, 2017 by avibootz
edited Sep 6, 2024 by avibootz

Related questions

1 answer 203 views
1 answer 195 views
1 answer 233 views
3 answers 381 views
1 answer 258 views
1 answer 177 views
...