PC Review


Reply
Thread Tools Rate Thread

Advantage between (int) and Convert.ToInt32?

 
 
=?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
Guest
Posts: n/a
 
      16th Feb 2005
Is there any advantage, or a recommended preference, between using (int) or
Convert.ToInt32() to convert numeric types to System.Integer32 ?

Thanks,
 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      16th Feb 2005
Hi,

They are two different concepts, the first is a cast , for this to work the
casted type should be convertible to int , no all of the types are.

The second are a series of method with different signatures, each overloaded
version perform the needed conversion.

IMO a cast should be faster than calling Convert.XXX but I cannot garantee
it, it does depend of the typed being converted.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



"charliewest" <(E-Mail Removed)> wrote in message
news:B34B0162-6772-4D9A-A952-(E-Mail Removed)...
> Is there any advantage, or a recommended preference, between using (int)
> or
> Convert.ToInt32() to convert numeric types to System.Integer32 ?
>
> Thanks,



 
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
Convert::ToInt32 problem Dave Farquharson Microsoft Dot NET Framework 3 9th May 2008 11:02 PM
IsNumeric: Convert.ToInt32 vs. Convert.ToInt64 sck10 Microsoft ASP .NET 4 3rd Sep 2006 10:40 PM
Difference between Cint and Convert.ToInt32 ? =?Utf-8?B?UmljaA==?= Microsoft VB .NET 4 22nd Jul 2006 05:50 AM
Convert.ToInt32(char) omeraa@gmail.com Microsoft Dot NET Framework 1 17th Jan 2006 07:23 AM
(int) or convert.ToInt32 ? =?Utf-8?B?SmFyb2Q=?= Microsoft C# .NET 8 22nd Jun 2005 07:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:50 AM.