I have a string array like:
string [] items = {\"one\",\"two\",\"three\",\"one\",\"two\",\"one\"};
I would like to replace all ones with z
string[] items = { "one", "two", "three", "one", "two", "one" };
If you want it the index way as you specified:
int n=0;
while (true)
{
n = Array.IndexOf(items, "one", n);
if (n == -1) break;
items[n] = "zero";
}
But LINQ would be better
var lst = from item in items
select item == "one" ? "zero" : item;