Hi Alice,
We can use an implicit type conversion that may fail at runtime. This means
that some string values do not have an obvious analogue as a number or
Boolean.
Using explicit type conversions, which allow for lossy conversions, makes
code more reliable and much less likely to fail at runtime.
Hope this helps.
Best Regards,
Mona [Grapecity]
> which method i can use for converting a string to a number?
>
> x10000 thanks
meckdahl@yahoo.com - 30 Aug 2005 23:25 GMT
Alice,
I had problems with the conversions, too. Here is a code snippet of my
solution: ( I am reading power data from an instrument)
double m_dTemp, m_dCh1LastPower; //
// This bypasses conversion error that shows up,
// Error is on return value of "" (Empty sting)
if ( Double.TryParse(strReading,
System.Globalization.NumberStyles.Float,
null, out m_dTemp) )
{ // True on successful conversion, so use it
m_dCh1LastPower = m_dTemp;
// To modify and return to string
m_dCh1LastPower = m_dCh1LastPower * 1000;
String sFormatter = "#0.00";
string txtNew = m_dCh1LastPower.ToString(sFormatter)
}
> Hi Alice,
>
[quoted text clipped - 14 lines]
> >
> > x10000 thanks