C# replace string in string

Viewed 64697

Is it possible to replace a substring in a string without assigning a return value?

I have a string:

string test = "Hello [REPLACE] world";

And I want to replace the substring [REPLACE] with something else:

test = test.replace("[REPLACE]", "test");

This works fine, but how can I do it without assigning the return value to a variable?

I want something like this:

test.replace("[REPLACE]", "test");
7 Answers
Related