Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

I am Jalpesh Vadgama a Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 6 years of experience in .NET Technology.
Browse by Tags · View All
#ASP.NET 88
#DOTNET 87
BRH 79
ASP.NET 72
#.NET 52
C#.NET 48
DOTNET 44
ASP.NET 4.0 31
ASP.NET MVC 29
VisualStudio 27

Archive · View All
December 2010 16
July 2011 13
April 2011 13
April 2012 12
January 2011 12
June 2011 11
May 2011 11
May 2012 8
February 2013 7
January 2013 7

Difference between int.Parse and Convert.ToInt32

Nov 26 2010 2:14PM by Jalpesh   

I know this post sound basic to most of people but still lots of people does not know this. So I decided to post a blog post for this. Both int.Parse and Convert.ToInt32 are used to convert string into the integer but Only difference between them is to Convert.ToInt32 handle null and returns ‘0’ as output and int.parse is not going to handle NULL and will give a Argument Null Exception. Here is the example for that both are almost same except handling null.

    
        string convertToInt = "12";
           string nullString = null;
           string maxValue = "32222222222222222222222222222222222";
           string formatException = "12.32";

           int parseResult;

           // It will perfectly convert interger
           parseResult= int.Parse(convertToInt);

           // It will raise Argument Null Exception
           parseResult= int.Parse(nullString);

           //It willl raise Over Flow Exception
           parseResult= int.Parse(maxValue);

           //It will raise Format Exception
           parseResult= int.Parse(formatException);


           //For Convert.ToInt32
        
           //It will perfectly convert integer
           parseResult= Convert.ToInt32(convertToInt);

           //It will ouput as 0 if Null string is there
           parseResult= Convert.ToInt32(nullString);

           //It will raise Over Flow Exception
           parseResult= Convert.ToInt32(maxValue);

           //It will raise Format Exception
           parseResult= Convert.ToInt32(formatException);

Hope this will help you understand the better but still there is third option available called int.TryParse which can handle all kind of exception and return result as Output Parameter.

Shout it

Tags: C#.NET, BRH, #DOTNET, #ASP.NET, int.parse, Convert.ToInt32,


Jalpesh
15 · 11% · 3478
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]