Use DirectCast when you just need to cast an object, without any conversion.
For example, if you have a reference to an object type, but you know the
object is actually a string, you can DirectCast the object to a string. Use
CType when you need might need to convert an object from one type to
another.
For example,
Dim x as Integer = Ctype("12345", Integer)
In this example, "12345" is a string, but can be converted to an integer.
You can't use DirectCast with this because a string isn't an integer. When
in doubt, use CType (or CInt, CStr, etc.) instead of DirectCast.
Finally, most VB functions have an equivalent function using .Net Framework
functions. (Most VB functions are actually just wrappers for the Framework
methods.) For example, IsDate corresponds (roughly) to
System.DateTime.Parse. In a pinch, you can use certain VB functions inside
of a C# project by importing the Microsoft.VisualBasic library into your C#
project.
If you're not sure about which language to use, check out this ebook:
http://www.desaware.com/products/books/net/vborc/index.aspx
Thanks for the replies...
So I should DirectCast to an integer instead of using CInt? I'm still
considering converting to C# as most professional components are C#... but
the one thing I didn't want to loose is the IsDate and IsNumeric functions!