Strings are
immutable. You cannot modify any strings.
I think you need something very different: to obtain one string from another, with some text removed, such as
string name =
name = name.Replace("Mishra", string.Empty);
In this line, you create a brand new string object; old object will be eventually discarded (by Garbage Collector, some time later). The variable
name
will loose its
referential identity as a result of operation, that is, not only the referenced object is new, but, as a result, the reference itself is new.
(You should understand here, that if you have a variable/field of reference type, it consist of two parts: a reference as object and the referenced object, the reference object always stored on heap, the reference can be somewhere else.)
—SA