You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the String.Remove method which takes only a startIndex parameter, you may pass a startIndex equal to the length of the string and the string returned is the same as the string passed in. This contradicts the remarks in the documentation:
The value of the startIndex parameter can range from zero to one less than the length of the string instance."
The documentation states that an ArgumentOutOfRangeException is thrown if "startIndex specifies a position that is not within this string." However, this does not happen.
This method calls Substring which states an ArgumentOutOfRangeException is thrown if "startIndex is less than zero or greater than the length of this instance." That wording would make more sense than the current documentation for the exception in Remove.
Type of issue
Other (describe below)
Description
In the String.Remove method which takes only a startIndex parameter, you may pass a startIndex equal to the length of the string and the string returned is the same as the string passed in. This contradicts the remarks in the documentation:
The documentation states that an ArgumentOutOfRangeException is thrown if "startIndex specifies a position that is not within this string." However, this does not happen.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.string.remove?view=net-9.0#system-string-remove(system-int32)
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/String.xml
Document Version Independent Id
bf50904f-f0ff-1d7f-b23e-6ad2e08930ce
Platform Id
c27a4a36-d9f6-1645-1e78-92b328516d7b
Article author
@dotnet-bot
The text was updated successfully, but these errors were encountered: