CSharp examples for System:String Strip
Remove Last Symbol If Exists
using System.Text.RegularExpressions; using System.Text; using System.Linq; using System.Collections.Generic; using System;// www .j ava 2 s.co m public class Main{ public static string RemoveLastSymbolIfExists(this string src, char symbol) { if (string.IsNullOrEmpty(src)) return src; return src[src.Length - 1] == symbol ? src.Substring(0, src.Length - 1) : src; } }