How to replace elements in an array of type T?
I have an Array2D<T> class that can take integer, reference types, etc. They are stored in this:
I have a method here that should replace elements.
I can't find any existing replace method. Any suggestions?
8 Replies
uhm wouldn't replace take also a index as argument?
also by replace you mean assigning?
This would change any element that matched from and replace it with to.
Maybe
m_array[Array.IndexOf(m_array, from)] = to;
?yeah, that but with a loop
like that maybe
It works, thanks!
from is kind of a reserved word just remember it
It's a contextual keyword.