keyongtech


  keyongtech > dotnet.languages.* > dotnet.languages.vb

 #1  
01-10-08, 10:15 PM
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.
 #2  
01-10-08, 10:41 PM
Kerry Moorman
kimiraikkonen,

http://www.panopticoncentral.net/arc...07/10/149.aspx

Kerry Moorman

"kimiraikkonen" wrote:
[..]
 #3  
01-10-08, 10:41 PM
Armin Zingler
"kimiraikkonen" <kimiraikkonen85> schrieb
> 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
 #4  
01-10-08, 10:43 PM
Armin Zingler
"kimiraikkonen" <kimiraikkonen85> schrieb
> 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
 #5  
01-10-08, 10:47 PM
kimiraikkonen
On Jan 11, 1:41 am, Kerry Moorman
<KerryMoor> wrote:
> kimiraikkonen,
>
> [..]
>
> Kerry Moorman
>>

> "kimiraikkonen" wrote:
>> - Show quoted text -


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

and

thanks Armin for the explanation.
 #6  
01-11-08, 08:27 AM
kimiraikkonen
On Jan 11, 1:47 am, kimiraikkonen <kimiraikkone> wrote:
[..]
>>

> 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 :-)
 #7  
01-11-08, 06:33 PM
Stephany Young
Yet another good reason for NOT using a web-based 'portal' for accessing
usenet newsgroups.


"kimiraikkonen" <kimiraikkonen85> wrote in message
news:6ca2
On Jan 11, 1:47 am, kimiraikkonen <kimiraikkone> wrote:
[..]
>>

> 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 :-)
 #8  
01-11-08, 06:52 PM
kimiraikkonen
On Jan 11, 9:33 pm, "Stephany Young" <noone@localhost> wrote:
[..]
>>
>>

>
> 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.
 #9  
01-11-08, 06:57 PM
Tom Shelton
On 2008-01-11, kimiraikkonen <kimiraikkonen85> wrote:
> On Jan 11, 9:33 pm, "Stephany Young" <noone@localhost> wrote:
>
> 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 :)
 #10  
01-11-08, 07:28 PM
Jack Jackson
On Fri, 11 Jan 2008 11:52:50 -0800 (PST), kimiraikkonen
<kimiraikkonen85> wrote:

>On Jan 11, 9:33 pm, "Stephany Young" <noone@localhost> wrote:
>
>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.


I use Agent. <http://www.forteinc.com/main/homepage.php>
Similar Threads
directcast

can anyone explain the directcast code...ive tried using it and lookin it up but im lookin for an easy definition and how it works...ive tried using it before byut it throws...

DirectCast invalid

Hello I have the following code: Public Groupes As New Hashtable Dim Entry As DictionaryEntry For Each Entry In Groupes Dim Gr As Groupe = DirectCast(Entry.Value,...

DirectCast in .NET 2.0

I can't find it .. what am I missing? - Sahil Malik [..]

directCast

Can I use DirectCast to convert a object to it's base or should I use CType? I have a instance of a class as Object. The run-time tipe is a derived of a class, but I need to...


All times are GMT. The time now is 07:03 PM. | Privacy Policy