public int IndexOf(char c, int start, int count)
        {
            var offset = Offset + start;

            if (!HasValue || start < 0 || (uint)offset > (uint)Buffer.Length)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
            }

            if (count < 0)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count);
            }

            var index = Buffer.IndexOf(c, offset, count);

            if (index != -1)
            {
                index -= Offset;
            }

            return(index);
        }
        private void ThrowInvalidArguments(int offset, int length)
        {
            throw GetInvalidArgumentsException(HasValue);

            Exception GetInvalidArgumentsException(bool hasValue)
            {
                if (!hasValue)
                {
                    return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.offset));
                }

                if (offset < 0)
                {
                    return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.offset));
                }

                if (length < 0)
                {
                    return(ThrowHelper.GetArgumentOutOfRangeException(ExceptionArgument.length));
                }

                return(ThrowHelper.GetArgumentException(ExceptionResource.Argument_InvalidOffsetLengthStringSegment));
            }
        }