Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Thu, 30 Aug 2007 19:56:02 -0700,    group: microsoft.public.dotnet.academic        back       


When to use variables, objects and CTYPE?   
Hello
Under what conditions "must" you use "CTYPE" when working with variables and 
objects?
date: Thu, 30 Aug 2007 19:56:02 -0700   author:   winlin

Re: When to use variables, objects and CTYPE?   
"winlin"  wrote in message 
news:20A3E762-5DC3-409E-ACBB-192BD3864046@microsoft.com...
> Hello
> Under what conditions "must" you use "CTYPE" when working with variables 
> and
> objects?

Can you provide some sort of contextual information on what you want to do 
that you believe needs ctype?
Normally, if I need to make a specific conversion that requires "forcing, I 
use explicit_cast<type>(argument).
date: Fri, 31 Aug 2007 18:55:12 -0500   author:   PvdG42

Re: When to use variables, objects and CTYPE?   
You must use CType when your code has the OPTION STRICT ON either in the 
project properties or in the VB Code itself and when the conversion is a 
narrowing one.

For instance, you can always write:  Dim i as Integer
                                                       Dim d as Double = i
But if you have set "Option strict On" in the project properties or in the 
code, Dim d as Double
                                                                             
                                        Dim i as Integer = d will not 
compile,
                                                                             
            you have to write:  Dim d as Double
                                                                             
                                         Dim i as Integer = CType(d, double) 
(it's a way to tell the compiler that you know what you are 
doing)
For objects, if Customer Inherits from Person, you can always write: Dim C 
as new Customer
                                                                             
                            Dim P as Person = C
But with Option Strict On, if you write Dim C as new Customer
                                                           Dim P as Person = 
C
                                                           Dim D as Customer 
= P, the compiler will not accept the last statement
it will accept: Dim C as new Customer
                     Dim P as Persomn = C
                     Dim D as Customer = CType(P, Customer)

I hope I am clear enough. Sometimes my students understand what I say.

Marc Biotteau, MCT

"winlin"  wrote in message 
news:20A3E762-5DC3-409E-ACBB-192BD3864046@microsoft.com...
> Hello
> Under what conditions "must" you use "CTYPE" when working with variables 
> and
> objects?
date: Tue, 27 Nov 2007 21:57:26 -0500   author:   Wannano

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us