Issue with String Extension in C# : <p>I am trying to make a simple string extension that assigns the changes to the original string (like toUpper).In this case, the method is assigning the contents to a second argument if it is neither white space nor null...otherwise, it leaves the current value in place, or assigns a null value to "". So, I would like to have it go:</p>

<pre><code>somerecord.Property1.func(someobj.property);
somerecord.Property2.func(someobj.otherproperty);
somerecord.Property3.func(someobj.anotherproperty);
</code></pre>

<p>while my code looks like</p>

<pre><code>    public static string func(this String str, string replacement)
    {
        if (!String.IsNullOrWhiteSpace(replacement)) {
            str = replacement;
            return replacement;
        }
        else
        {
            if(str == null)
              str = "";
            return "";
        }
    }
</code></pre>

<p>I wanted to set <code>this</code> to <code>ref</code> but I can't. Any ideas on how to implement this cleanly?</p>
