Which one is better to use? CInt(string) or Integer.Parse(s tring)? thanks! 15 27853
* "Brian Henry" <br**********@n ewsgroups.nospa m> scripsit: Which one is better to use? CInt(string) or Integer.Parse(s tring)? thanks!
Personal preference.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:ua******** ******@TK2MSFTN GP12.phx.gbl... Which one is better to use? CInt(string) or Integer.Parse(s tring)? thanks!
Depends on whether you want to retain the VB "feel" or go hardcore Framework
all the way.
been trying to knock out all the old vb stuff out of my head so sounds like
the parse one is good to go with :)
"Jeff Johnson [MVP: VB]" <i.***@enough.s pam> wrote in message
news:Of******** ******@tk2msftn gp13.phx.gbl... "Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message news:ua******** ******@TK2MSFTN GP12.phx.gbl...
Which one is better to use? CInt(string) or Integer.Parse(s tring)?
thanks! Depends on whether you want to retain the VB "feel" or go hardcore
Framework all the way.
Brian,
I would use CInt, unless I specifically needed to use Integer.Parse. As
Herfried stated its largely personal preference.
For details on CInt vs. Integer.Parse and details on other myths about
avoiding VB in your VB.NET see: http://www.panopticoncentral.net/arc...5/31/1100.aspx http://www.panopticoncentral.net/arc...6/07/1200.aspx
Hope this helps
Jay
"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:ua******** ******@TK2MSFTN GP12.phx.gbl... Which one is better to use? CInt(string) or Integer.Parse(s tring)? thanks!
* "Brian Henry" <br**********@n ewsgroups.nospa m> scripsit: been trying to knock out all the old vb stuff out of my head so sounds like the parse one is good to go with :)
'CInt' is not "old vb". It's current VB syntax that /should/ be used
/instead/ of the framework functions whenever possible. That's why we
have these commands.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
I agree that Integer.Parse is the wrong thing to use - but CType(xx,
Integer) is functionally identical to CInt - and if you happen to not have
Microsoft.Visua lBasic referenced... it's fine :D
_______________ _______________ _
The Grim Reaper
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:eX******** ******@TK2MSFTN GP11.phx.gbl... * "Brian Henry" <br**********@n ewsgroups.nospa m> scripsit: been trying to knock out all the old vb stuff out of my head so sounds
like the parse one is good to go with :)
'CInt' is not "old vb". It's current VB syntax that /should/ be used /instead/ of the framework functions whenever possible. That's why we have these commands.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
* "The Grim Reaper" <gr*********@bt openworld.com> scripsit: I agree that Integer.Parse is the wrong thing to use - but CType(xx, Integer) is functionally identical to CInt - and if you happen to not have Microsoft.Visua lBasic referenced... it's fine :D
Both, 'CInt' and 'CType' are VB /keywords/ that should work without
referencing this library.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
any reason specific reason why you suggest i should use CInt instead of the
framework versions? I'm trying to maintain as much compatability in tearms
of code with C# incase they ever want this code directly coverted over to
it..
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:eX******** ******@TK2MSFTN GP11.phx.gbl... * "Brian Henry" <br**********@n ewsgroups.nospa m> scripsit: been trying to knock out all the old vb stuff out of my head so sounds like the parse one is good to go with :)
'CInt' is not "old vb". It's current VB syntax that /should/ be used /instead/ of the framework functions whenever possible. That's why we have these commands.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
Hi Brian,
One of the things in the language itself where VB is much better than all
the other languages in dotNet are the *convert* functions.
You have the change to use that benefit, not using them is for me the same
as getting a million and not accepting it because it is not given to
everybody.
Just my thougth,
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kenneth |
last post by:
What's the different between this
CInt(iID)
Integer.Parse(iID)
|
by: Atara |
last post by:
In my apllication I use the following code:
'-- My Code:
Public Shared Function strDate2Date(ByVal strDate As String) As
System.DateTime
Dim isOk As Boolean = False
If (strDate Is Nothing) Then
isOk = False
ElseIf Not (strDate.Length() = 6) Then
isOk = False
|
by: Teresa |
last post by:
1) Should I use Integer.Parse to convert a string into an integer in .NET
now?
CType(sUserID, Integer) OR Integer.Parse(sUserID)
2) And is it better to use the string class to trim, get length, etc in .NET?
s1.trim OR trim(s1)
s1.length OR len(s1)
Thank you!
|
by: Jim in Arizona |
last post by:
I'm familiar with CInt(value) but I'm not with Int32.Parse(value). They seem
to do the same thing. Is there a big difference between the two and when
would one be best applied over the other?
Thanks,
Jim
|
by: Joergen Bech |
last post by:
Basically, I want to convert hex values in the range
"00000000" to "FFFFFFFF" to a signed, 32-bit Integer
value.
In VB6, I could just write lngValue = Val(hexstring$).
In VB.Net, I seem to be forced to do something like
---snip---
Private Function HexToInteger(ByVal hexValue As String) As Integer
| |
by: Joe |
last post by:
Hello All:
Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the other?
TIA,
--
Joe
|
by: Rich |
last post by:
Hello
txtID.Text contains a 6 digit Integer number with no decimals, no chars...
Dim j As Integer = Cint(txtID.Text)
or
Dim j As Integer = Convert.ToInt32(txtID.Text)
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |