Re: VB Conversion Keywords And .NET Conversion Routines

From: Bob Grommes (bob_at_bobgrommes.com)
Date: 03/01/05


Date: Tue, 1 Mar 2005 09:36:11 -0700

I'm given to understand that CType() itself is in fact equivalent to the
corresponding Convert methods, and that DirectCast is about the same as a C#
cast, which is faster since it's a cast rather than a conversion.

In reality I'm not sure that we're doing anything but splitting hairs here
though ... this conversation is interesting but ultimately, in real world
line of business scenarios, the differences in performance are not that
significant. If we were doing matrix math or image manipulation, it might
matter. But if we're simply unboxing datarow values and converting textbox
strings to integer or decimal, and other *typical* operations, it probably
doesn't in fact matter how you accomplish it, from a performance
perspective. So I go for consistency and use metaphors that would be
familiar to any developer who knows the .NET framework, regardless of their
language experience.

--Bob

"Scott M." <s-mar@nospam.nospam> wrote in message
news:e8%23tzEnHFHA.588@TK2MSFTNGP15.phx.gbl...
> Well, I don't necessarily agree, in that with CType, there is just one
> function to use. Rather than the 5 or 6 legacy conversion functions. I
> find CType to be more consistent.



Relevant Pages

  • Re: Collections
    ... cast an abstract class into a derived class ... First remember that DirectCast is the Cast operator, while CType is the ... Conversion operator that will do a Cast if the cast is allowed. ... remember that Casting & Converting are separate ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Arghhh...strict, but not strict enough
    ... You don't get a conversion with CType. ... difference between CType and directcast? ... only - if I want to cast. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Arghhh...strict, but not strict enough
    ... That's not what happens with CType. ... convert and cast as that is possible instead. ... output parametes are reference and value types or vice versa. ... A conversion implies that the original data is transformed into something ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB Conversion Keywords And .NET Conversion Routines
    ... I'm given to understand that CType() itself is in fact equivalent to the ... cast, which is faster since it's a cast rather than a conversion. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Arghhh...strict, but not strict enough
    ... happens with CType. ... As for DirectCast, my description IS correct: ... before the cast of the reference is done. ...
    (microsoft.public.dotnet.languages.vb)