Answers for "stringbuilder remove last character c#"

32

c# remove last character from string

string Name = "Teste,"
string ReturnName = "";
ReturnName = Name.Remove(Name.Length - 1);
Posted by: Guest on June-19-2020
6

remove last character from string c#

myString = myString.Substring(0, myString.Length-1);
Posted by: Guest on March-10-2021
1

stringBuilder delete last character

public class StringBuilderRemoveLastCharacterExample {
 
    public static void main(String[] args) {
        
        //creates an empty StringBuilder object
        StringBuilder sbld = new StringBuilder();
        
        int[] numbers = {1, 2, 3, 4, 5};
        
        for(int number : numbers){
            sbld.append(number).append(",");
        }
        
        System.out.println("StringBuilder contains: " + sbld);
        
        /*
         * To remove last character from StringBuilder, use
         * the deleteCharAt method
         */
        
        //always make sure to check the length to avoid exception
        if( sbld.length() > 0 )
            sbld.deleteCharAt( sbld.length() - 1 );
        
        System.out.println("StringBuilder contains: " + sbld);
    }
}
Posted by: Guest on June-08-2021

Code answers related to "stringbuilder remove last character c#"

Browse Popular Code Answers by Language