Converting String (-) to Double in C#
<p>Is it possible to convert a string value to double?</p>

<p>For example: double datatype used to display <code>0.00</code> right?<br>
Now, what I want to output is if the value or result is equal to <code>0.00</code> then that value should be converted to a hyphen <code>-</code>.</p>

<pre><code>if (value == 0)
{
    x = "-";
}
</code></pre>

<p>then display x should be converted to double again since I use double in <code>Crystal Report</code>.</p>

<p>Here is my code that gives an error.</p>

<pre><code>TCPS = TotalCPS + PSAmount;
TAPPS = TotalAPPS + PSAmount2;
if (TCPS==0)
{
    TCPS = Convert.ToDouble("-");
}
else if (TCPS &gt; 0)
{
    TCPS = TCPS + 0;
}
row["CPS"] = TCPS;
</code></pre>

<p><code>CPS</code> here is a <code>Double</code> datatype and the value of that <code>CPS</code> will be displayed in <code>Crystal Report</code> that's why I need to output a Hypen <code>-</code> instead of <code>0.00</code> in the report. I hope this gives you a more clearer info. Thanks</p>

<p><strong>EDIT:</strong>
Thank you so much guys! I already figured it out! Here's what I did.</p>

<pre><code>            TCPS = TotalCPS + PSAmount;
            TAPPS = TotalAPPS + PSAmount2;
            if (TCPS==0)
            {
                row["CPS"] = "-";
            }
            else if (TCPS &gt; 0)
            {
                row["CPS"] = string.Format("{0:N}", TCPS);
            }
</code></pre>

<p>I changed the datatype of CPS from double to string and that relieves me from stress..:)
Thank you..</p>