private int IndexOfCharOrdinalIgnoreCase(char value) { if (!char.IsAscii(value)) { return(CompareInfo.Invariant.IndexOf(this, value, CompareOptions.OrdinalIgnoreCase)); } if (char.IsAsciiLetter(value)) { char valueUc = (char)(value | 0x20); char valueLc = (char)(value & ~0x20); return(SpanHelpers.IndexOfAnyChar(ref _firstChar, valueLc, valueUc, Length)); } return(SpanHelpers.IndexOfChar(ref _firstChar, value, Length)); }
public unsafe int IndexOf(char value, int startIndex, int count) { if ((uint)startIndex > (uint)Length) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_IndexMustBeLessOrEqual); } if ((uint)count > (uint)(Length - startIndex)) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count); } int result = SpanHelpers.IndexOfChar(ref Unsafe.Add(ref _firstChar, startIndex), value, count); return(result < 0 ? result : result + startIndex); }
// Returns the index of the first occurrence of a specified character in the current instance. // The search starts at startIndex and runs thorough the next count characters. public int IndexOf(char value) => SpanHelpers.IndexOfChar(ref _firstChar, value, Length);