PC Review


Reply
Thread Tools Rate Thread

Cint or Integer.Parse?

 
 
Brian Henry
Guest
Posts: n/a
 
      15th Jul 2004
Which one is better to use? CInt(string) or Integer.Parse(string)? thanks!


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      15th Jul 2004
* "Brian Henry" <(E-Mail Removed)> scripsit:
> Which one is better to use? CInt(string) or Integer.Parse(string)? thanks!


Personal preference.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Jeff Johnson [MVP: VB]
Guest
Posts: n/a
 
      15th Jul 2004

"Brian Henry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Which one is better to use? CInt(string) or Integer.Parse(string)? thanks!


Depends on whether you want to retain the VB "feel" or go hardcore Framework
all the way.


 
Reply With Quote
 
Brian Henry
Guest
Posts: n/a
 
      15th Jul 2004
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Brian Henry" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > Which one is better to use? CInt(string) or Integer.Parse(string)?

thanks!
>
> Depends on whether you want to retain the VB "feel" or go hardcore

Framework
> all the way.
>
>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      15th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Which one is better to use? CInt(string) or Integer.Parse(string)? thanks!
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      15th Jul 2004
* "Brian Henry" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
The Grim Reaper
Guest
Posts: n/a
 
      16th Jul 2004
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.VisualBasic referenced... it's fine
_______________________________
The Grim Reaper

"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> * "Brian Henry" <(E-Mail Removed)> 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/>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Jul 2004
* "The Grim Reaper" <(E-Mail Removed)> 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.VisualBasic referenced... it's fine


Both, 'CInt' and 'CType' are VB /keywords/ that should work without
referencing this library.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Brian Henry
Guest
Posts: n/a
 
      16th Jul 2004
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]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>* "Brian Henry" <(E-Mail Removed)> 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/>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Jul 2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie - parse number into integer and decimal portions dakota64 Microsoft VB .NET 3 12th Oct 2007 01:39 PM
CType(x,Integer) vs. Integer.Parse(x) =?Utf-8?B?Sm9l?= Microsoft ASP .NET 7 7th Feb 2006 02:30 AM
Integer.Parse lgbjr Microsoft VB .NET 3 13th May 2005 04:28 AM
cint and int32.parse Jim in Arizona Microsoft VB .NET 16 13th Apr 2005 03:45 AM
Use CType or Integer.Parse to parse a string into an integer =?Utf-8?B?VGVyZXNh?= Microsoft VB .NET 8 27th Jan 2005 03:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:55 PM.