Casting is certainly faster while converting is more flexible (it can
convert various types while cast doesn't convert).

Signature
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info
> hi everyone
>
> which is more efficient: casting or using the convert class? please give
> reasons.
>
> tia
john conwell - 15 Jun 2005 16:49 GMT
wooo...hold on there. It depends on what type to what type your casting.
If you take a look at the Convert class using Reflector
(www.aisto.com/roeder/dotnet) most of the methods in Convert do a straight
cast. convertions that can be safely casted are just casted. Others are
checked for upper and lower bounds and throw exceptions of it wont be a safe
cast (long to an int). Some methods just return the passed in value (int to
an int).
Best thing to do when you want to know how somethign works...look at the
code in Reflector
> Casting is certainly faster while converting is more flexible (it can
> convert various types while cast doesn't convert).
[quoted text clipped - 5 lines]
> >
> > tia