Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Array.Reverse() reverses a string without assignment?

Tags:

c#

How does Array.Reverse() method reverse an array of word without any assignment?

like image 507
syaur Avatar asked Feb 02 '26 05:02

syaur


1 Answers

The method modifies the array itself, so you can use it in its reversed state right away; there is no need to return a copy of the array to assign back to your existing variable. Arrays are reference types, so their contents can be modified in place without reassigning.

See the MSDN entry for Array.Reverse(), and arrays in the C# programming guide.

like image 165
BoltClock Avatar answered Feb 03 '26 17:02

BoltClock