c# finding indexof and remove character atsign
<p>there is a String which contains some @ characters, i want to find " @ " in my string and remove them, but it also finds and removes these ones: "@"</p>

<pre><code>int atsignPlace = str.IndexOf(" @ ");
while (atsignPlace &gt;= 0)
{
    str = str.Remove(atsignPlace,3);
    atsignPlace = str.IndexOf(" @ ");
}
</code></pre>

<p>i tried this code, but it removes nothing, so it always finds first '@' ,which makes it an infinite loop.</p>

<pre><code>int atsignPlace = str.IndexOf(" @");
while (atsignPlace &gt;= 0)
{
    if( atsignPlace+1 &lt; str.Length &amp;&amp; str[atsignPlace+1] == ' ' )
        str = str.Remove(atsignPlace,3);
    atsignPlace = str.IndexOf(" @ ");
 }
</code></pre>

<p>Replace method also doesn't work correct. </p>

<pre><code>str = str.Replace(" @ ", String.Empty);
</code></pre>

<p>maybe there is a problem with '@' character.</p>

<p>the input string is a sql query, i am trying to remove some parameters from it.</p>

<p>[ i have used try-catch for exceptions ]</p>
