Show / Hide Table of Contents

Method ExtString.Starts(+ 3 overloads)


Overload

Compares beginning of this string with other string. Returns true if equal.

public static bool Starts(this string t, ReadOnlySpan<char> s, bool ignoreCase = false)
Parameters
t  (string)

This string.

s  (ReadOnlySpan<char>)

Other string.

ignoreCase  (bool)

Case-insensitive.

Returns
bool
Exceptions
ArgumentNullException

s is null.

Remarks

Uses ordinal comparison (does not depend on current culture/locale).


Overload(next)

Compares beginning of this string with multiple strings. Returns 1-based index of the matching string, or 0 if none.

public static int Starts(this string t, bool ignoreCase, params ReadOnlySpan<string> strings)
Parameters
t  (string)

This string.

ignoreCase  (bool)

Case-insensitive.

strings  (ReadOnlySpan<string>)

Other strings.

Returns
int
Exceptions
ArgumentNullException

A string in strings is null.

Remarks

Uses ordinal comparison (does not depend on current culture/locale).


Overload(next)

Returns true if this string starts with the specified character.

public static bool Starts(this string t, char c)
Parameters
t  (string)

This string.

c  (char)

Character.

Returns
bool

Overload(top)

Returns true if starts with string s.

public static bool Starts(this ReadOnlySpan<char> t, ReadOnlySpan<char> s, bool ignoreCase = false)
Parameters
t  (ReadOnlySpan<char>)

This span.

s  (ReadOnlySpan<char>)

Other string.

ignoreCase  (bool)

Case-insensitive.

Returns
bool

Remarks

Uses ordinal comparison (does not depend on current culture/locale).