Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another? 8 5192
"winlin" <wi****@verizon .comschrieb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
Because it's shorter. "CInt(s)" is shorter than "CType(s, Integer)"
Armin
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For backwards compatibility or for those who prefer to write in vb6 style.
-h-
winlin wrote:
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For when you want to do one kind of conversion, but not allow another.
There are several different ways of converting values, and they all fit
in different situations.
CType(stringVal ue, Integer) will for example convert a null string into
zero, but that is not always desirable. Sometimes you want a null value
to be considered illegal, and not silently converted.
Another example is casting of a known type. The DirectCast method is a
slightly faster, and it will only allow casting a reference into it's
actual type.
--
Göran Andersson
_____ http://www.guffa.com
"Heikki Leivo" <he************ @cadworksdotfi. removethisschri eb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
For backwards compatibility or for those who prefer to write in vb6
style.
Why is using the shorter, straight version "vb6 style"? These are all
commands, specialized on the destination type, that are even compiled
inline.
Armin
CType(x, Integer) is identical to CInt.
They will both convert a null string to zero.
In general, CType has identical behavior to the shorter CInt, CLng, etc.
macros (they aren't functions, but part of VB language syntax).
--
David Anton http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"Göran Andersson" wrote:
winlin wrote:
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For when you want to do one kind of conversion, but not allow another.
There are several different ways of converting values, and they all fit
in different situations.
CType(stringVal ue, Integer) will for example convert a null string into
zero, but that is not always desirable. Sometimes you want a null value
to be considered illegal, and not silently converted.
Another example is casting of a known type. The DirectCast method is a
slightly faster, and it will only allow casting a reference into it's
actual type.
--
Göran Andersson
_____ http://www.guffa.com
Absolutely.
CType, CInt, CLng, etc. are all a legit part of VB syntax and are not
related to any legacy libraries.
--
David Anton http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"Armin Zingler" wrote:
"Heikki Leivo" <he************ @cadworksdotfi. removethisschri eb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
For backwards compatibility or for those who prefer to write in vb6
style.
Why is using the shorter, straight version "vb6 style"? These are all
commands, specialized on the destination type, that are even compiled
inline.
Armin
David Anton wrote:
CType(x, Integer) is identical to CInt.
They will both convert a null string to zero.
Yes, of course. Other methods won't, like Int32.Parse for example.
--
Göran Andersson
_____ http://www.guffa.com
Hello! Good Site! Thanks you! uibdbmfwnwwdw This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joeri |
last post by:
Hi,
I'm struggling with this issue, maybe someone has already
solved ik before. Here's the problem
I Have :
clsA witch is a base class
clsB inherits from clsA
clsC inherits from clsA
clsD inherits from clsA
|
by: Logan X via .NET 247 |
last post by:
It's official....Convert blows.
I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance would be identical.
I was 100% incorrect.
The code below produces the results:
CType Took: 0.2187528 seconds.
Convert Took: 12.187656 seconds.
|
by: Mark Kamoski |
last post by:
Hi--
What is the difference between Convert.ToString(obj) and CType(obj,
String)?
(Assume obj is a variable of type Object.)
Please advise.
Thank you.
|
by: Mike Cooper |
last post by:
There is something about inherited classes I evidently don't know...
I wrote the following class:
Class Class1
inherits System.Windows.Forms.DataGridTextBoxColumn
End Class
There is absolutely no added functionality to it.
|
by: Ot |
last post by:
I apparently have a bit to learn about Casting and Conversion. I have been
thinking of them as the same but a discussion in another thread leads me to
believe that this is wrong thinking.
I found this in the VB Language reference:
<quote>
The DirectCast keyword introduces a type conversion operation. You use it
the same way you use the...
| |
by: John A Grandy |
last post by:
could someone please discuss the pros and cons of
CType(MyDouble,Decimal)
versus
Convert.ToDecimal(MyDouble)
.... and other such conversions ...
|
by: Brian Henry |
last post by:
is there any speed diffrences between doing Ctype or directcast? I know
about the inherite diffrences, but process usage time wise, does one take up
more cycles then the other? thanks
|
by: FB's .NET Dev PC |
last post by:
I'm trying to create a general-purpose routine to update a value in a data
location on a remote server. The client-server protocol is OPC, but that
isn't immediately important to my question. The part that is important is
that the value passed to the server has to be the correct data type. I am
trying to convert the input (as an object) to...
|
by: Todd Plambeck |
last post by:
Is there a more C# like alternative to CType? I don't like using the
VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
something like Convert.ToInt32(), but can't find a equivalent for converting
objects.
Thanks,
Todd
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |