yea that worked. thanks for the help guys
On Jun 8, 11:18 am, "Johnny J?rgensen" <j...@altcom.se> wrote:
> What happens if you try
>
[quoted text clipped - 32 lines]
>
> - Show quoted text -
cjard - 08 Jun 2007 16:30 GMT
Double.TryParse can be more useful...
Johnny Jörgensen - 08 Jun 2007 16:31 GMT
Great.
MS is recommending using direct casting (double) instead of Convert, but
often Convert will do the job where the direct casting fails (for some
reason I don't know)
Cheers,
Johnny J.
yea that worked. thanks for the help guys
On Jun 8, 11:18 am, "Johnny Jörgensen" <j...@altcom.se> wrote:
> What happens if you try
>
[quoted text clipped - 33 lines]
>
> - Show quoted text -
Jon Skeet [C# MVP] - 08 Jun 2007 16:50 GMT
On Jun 8, 4:31 pm, "Johnny J?rgensen" <j...@altcom.se> wrote:
> MS is recommending using direct casting (double) instead of Convert, but
> often Convert will do the job where the direct casting fails (for some
> reason I don't know)
The reason in this case is simple - you can't cast from a string to a
double, but you can convert from a string to a double.
Jon
On Jun 8, 8:18 pm, "Johnny J?rgensen" <j...@altcom.se> wrote:
> What happens if you try
>
[quoted text clipped - 32 lines]
>
> - Show quoted text -
try
{
double x = Double.Parse(myReader["TimeStamp"]);
}
catch(....)/Handle exception here. If the string contains data that
cannot be parsed to double it would throw exception.)
{
..........
..........
}
Aneesh Pulukkul[MCSD.Net] - 08 Jun 2007 16:37 GMT
On Jun 8, 8:30 pm, "Aneesh Pulukkul[MCSD.Net]" <anees...@gmail.com>
wrote:
> On Jun 8, 8:18 pm, "Johnny J?rgensen" <j...@altcom.se> wrote:
>
[quoted text clipped - 50 lines]
>
> - Show quoted text -
It seems Double.Parse accepts string parameters only.
Since this is an object, Convert.ToDouble is the apt one.
Aneesh Pulukkul[MCSD.Net] - 08 Jun 2007 16:38 GMT
On Jun 8, 8:30 pm, "Aneesh Pulukkul[MCSD.Net]" <anees...@gmail.com>
wrote:
> On Jun 8, 8:18 pm, "Johnny J?rgensen" <j...@altcom.se> wrote:
>
[quoted text clipped - 50 lines]
>
> - Show quoted text -
Or you can convert the value to string and then parse - better avoid
two conversions.
Ben Voigt [C++ MVP] - 08 Jun 2007 17:42 GMT
On Jun 8, 8:30 pm, "Aneesh Pulukkul[MCSD.Net]" <anees...@gmail.com>
wrote:
> On Jun 8, 8:18 pm, "Johnny Jörgensen" <j...@altcom.se> wrote:
>
[quoted text clipped - 54 lines]
>Or you can convert the value to string and then parse - better avoid
>two conversions.
Cast, not convert, the object to string. There would be only one
conversion, and an explicit cast should be far more efficient than calling
Convert.ToDouble(object) and having a dynamic type check.