Hi Marlon,
Thanks for your posting. I've also noticed your another thread in this
group.
As for converting object between types, I think the CType will always be
the preferred one since it just search to see whether it is possbile to
convert the source type to destination type, if not possible it failed and
the source and destination type don't need to have inheritance relation.
And if you're sure that the source type and the destination type has
inheritance relation, you can use
DirectCast keyword instead, that'll have better performance than CType ,
see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vbtchperfopt.asp
In addition, as for the third option you mentioned
3) System.ComponentModel.TypeDescriptor.GetConverter(
GetType(UploadMode)).ConvertFromxxxx(tmp)
I'm not sure why we need to use such means, as far as I known , the
TypeDescriptor and TypeConvertor will use a lot of Reflection apis during
the convertion which may have performance concerns at runtime.
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)