Re: what is the difference wetween Int32.parse and Convert.ToInt32
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 3 Feb 2007 07:54:33 -0000
psycho <paramvir.deol@xxxxxxxxx> wrote:
what is the difference between the two forms of converting to integer
from string
string strVal = "10";
Convert.ToInt32(strVal);
Int32.Parse(strVal);
Convert.ToInt32 returns 0 if you pass it null. Int32.Parse will throw
an exception.
which method is more efficient in terms of performance?
The difference is trivial. You should pick based on the semantics you
want.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
Relevant Pages
- Re: Current Exception
... > and set it yourself when the catch the exception (it HAS to be caught ... > Then in whatever code you are actually handling it, ... Jon Skeet - ... If replying to the group, please do not mail me too ... (microsoft.public.dotnet.languages.csharp) - Re: Cross-thread operation not valid
... > I get this Exception when I try to update some labels/textbox's from a ... Jon Skeet - ... If replying to the group, please do not mail me too ... Prev by Date: ... (microsoft.public.dotnet.languages.csharp) - Re: StreamReader.close and StreamWriter.close
... an Exception occurs? ... Either put a try/catch within the using statement, ... Jon Skeet - ... If replying to the group, please do not mail me too ... (microsoft.public.dotnet.languages.csharp) - Re: Newbie Question on Error Handling
... That wouldn't stop the current thread of executing. ... The ng response was that the exception was being ... Jon Skeet - ... If replying to the group, please do not mail me too ... (microsoft.public.dotnet.languages.csharp) - Re: Try Catch and Variables
... >> C# just doesn't allow return from finally at all, so no semantics need ... want - just as the Java designers chose that the return value would ... take precedence over the exception. ... If replying to the group, please do not mail me too ... (microsoft.public.dotnet.languages.csharp) |
|