<"Ignacio Machin \( .NET/ C# MVP \)" <machin TA laceupsolutions.com>>
wrote:
Sometimes you need two casts, but I think that's generally nicer than
formatting and then parsing.
Can you provide a case where you need two casting?
Yup - if you want something as an int, but it's currently a boxed
SqlInt32. Basically you need one cast for the unboxing, and another for
the explicit conversion:
using System;
using System.Data.SqlTypes;
class Test
{
public static void Main()
{
object o = new SqlInt32(10);
int x = (int) (SqlInt32) o;
}
}
(There are other ways of doing it, of course, but the above is about as
simple as it gets, IMO.)
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too