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 114 views
1 answer 124 views
1 answer 143 views
3 answers 220 views
1 answer 170 views
1 answer 105 views
...