Remove First Symbol If Exists - CSharp System

CSharp examples for System:String Strip

Description

Remove First Symbol If Exists

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;// w ww.  j ava  2 s.c o m

public class Main{
        public static string RemoveFirstSymbolIfExists(this string src, char symbol)
        {
            if (String.IsNullOrEmpty(src))
                return src;

            return src[0] == symbol ? src.Substring(1, src.Length - 1) : src;
        }
}

Related Tutorials