In C#, you can use the Array.ConvertAll
method to map the elements of an array to a new set of values. Here's an example using a lambda expression to multiply each element of an array by 2:
main.cs130 chars4 lines
Alternatively, you can use LINQ's Select
method to achieve the same effect:
main.cs129 chars4 lines
Both of these methods create a new array and do not modify the original array.
gistlibby LogSnag