-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Type of issue
Other (describe below)
Description
Enumerable.Prepend is defined as:
Adds a value to the beginning of the sequence.
However, later down the documentation within the Remarks section that mentions that:
This method does not modify the elements of the collection. Instead, it creates a copy of the collection with the new element.
And in the Examples section it demonstrates that this method does not work when trying to just Prepend the List since it does not modify the original list:
// Trying to prepend any value of the same type
numbers.Prepend(0);
// It doesn't work because the original list has not been changed
Console.WriteLine(string.Join(", ", numbers));
So why is the definition for this function something along the lines of:
"Returns a list with the value added to the beginning of the sequence"
Instead of:
"Adds a value to the beginning of the sequence."
Since that mis-leads you into thinking that it is modifying the original list.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.prepend?view=net-9.0
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Linq/Enumerable.xml
Document Version Independent Id
9556f661-a131-5b65-913f-50770cc980cf
Platform Id
acda5d20-c39a-4d6d-e70e-28d92c16a6b3