In Ruby you can use the map/collect method on an array to modify it:
a = [ "a", "b", "c", "d" ]
a.collect! {|x| x + "!" }
a #=> [ "a!", "b!", "c!", "d!" ]
Is there a simple way to do this in C#?
In Ruby you can use the map/collect method on an array to modify it:
a = [ "a", "b", "c", "d" ]
a.collect! {|x| x + "!" }
a #=> [ "a!", "b!", "c!", "d!" ]
Is there a simple way to do this in C#?
you may try this
var a = new[] { "a", "b", "c", "d" };
a = a.Select(p => p + "!").ToArray();
Yup, using Linq (but this won't modify the original collection)
var a=new[]{"a","b","c","d"};
a.Select(x=>x+"!");
I prefer using ConvertAll since it's quicker and I believe more intuitive.
var a = a.ConvertAll(x => x + "!").ToArray();