DevCode.Extensions/StringExtensions.cs
/// <summary>
/// Adds a char to beginning of given string if it does not starts with the char.
/// </summary>
Adds a char to beginning of given string if it does not starts with the char.
Adds a char to beginning of given string if it does not starts with the char .
public static string EnsureStartsWith(this string str, char c, bool ignoreCase, CultureInfo culture)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }
            if (str.StartsWith(c.ToString(culture), ignoreCase, culture))
            {
                return str;
            }
            return c + str;
        }
public static string EnsureStartsWith ( this string str , char c , bool ignoreCase , CultureInfo culture ) { if ( str == null ) { throw new ArgumentNullException ( nameof ( str ) ) ; } if ( str . StartsWith ( c . ToString ( culture ) , ignoreCase , culture ) ) { return str ; } return c + str ; }
Adds a char to beginning of given string if it does not starts with the char.
Adds a char to beginning of given string if it does not starts with the char .
string
this
c
char
ignoreCase
bool
culture
CultureInfo