DirectCast

  • Thread starter Thread starter kimiraikkonen
  • Start date Start date
K

kimiraikkonen

Hi,
I'm trying to learn the function of DirectCast and CType which are
similiar. Could you explain and sample a simple code that shows what
they exactly do and have differences?

Thanks.
 
kimiraikkonen said:
Hi,
I'm trying to learn the function of DirectCast and CType which are
similiar. Could you explain and sample a simple code that shows what
they exactly do and have differences?

DirectCast /only/ does type casting. Casting does not create a new
object, it just changes the type of the reference. This implicitly means
that the object must be of the destination type, derived from the
destination type or implement the destination interface.

CType either converts or casts. If it can not be casted, VB will try to
convert the source object to a new destination object. CType will be
compiled to whatever is necessary in the specific situation, depending
on the type of the source object and the destination type. In addition,
CType can be defined as a user defined operators.

For details please have a look at "Type Conversions in Visual Basic".
Too much to paste here.


Armin
 
kimiraikkonen said:
Hi,
I'm trying to learn the function of DirectCast and CType which are
similiar. Could you explain and sample a simple code that shows what
they exactly do and have differences?

DirectCast /only/ does type casting. Casting does not create a new
object, it just changes the type of the reference. This implicitly means
that the object must be of the destination type, derived from the
destination type or implement the destination interface.

CType either converts or casts. If it can not be casted, VB will try to
convert the source object to a new destination object. CType will be
compiled to whatever is necessary in the specific situation, depending
on the type of the source object and the destination type. In addition,
CType can be defined as a user defined operators.

For details please have a look at "Type Conversions in Visual Basic".
Too much to paste here.

[sorry, no example] ;)


Armin
 
Thanks for the link. I'll take a look.

and

thanks Armin for the explanation.- Hide quoted text -

- Show quoted text -

Meanwhile, it seems my first(main) message is not shown on Google
group page for a reason related to Google servers.(interesting).
Kerry's message is shown as first message :-)
 
Yet another good reason for NOT using a web-based 'portal' for accessing
usenet newsgroups.


Thanks for the link. I'll take a look.

and

thanks Armin for the explanation.- Hide quoted text -

- Show quoted text -

Meanwhile, it seems my first(main) message is not shown on Google
group page for a reason related to Google servers.(interesting).
Kerry's message is shown as first message :-)
 
Yet another good reason for NOT using a web-based 'portal' for accessing
usenet newsgroups.






Meanwhile, it seems my first(main) message is not shown on Google
group page for a reason related to Google servers.(interesting).
Kerry's message is shown as first message :-)

Which software do you suggest? And also its settings?

I took a look on classic Outlook Express 6 which reads messages fine,
but the posting requires SMTP server configuration which i don't know
for newsgroups.
 
Which software do you suggest? And also its settings?

I took a look on classic Outlook Express 6 which reads messages fine,
but the posting requires SMTP server configuration which i don't know
for newsgroups.

slrn :)
 
Back
Top