Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between int.Parse() and
Convert.toInt32().

Answer Posted / jyoti magdum

Both(Convert.ToInt32 and int.Parse) will return the same
result in
most of the cases.

string strCount="32";
int count1 = Convert.ToInt32(strCount);
int count2 = int.Parse(strCount);

If you print the result it will be same ie 32.

If suppose the string is the null (see the example below),
Convert.ToInt32 will throw ArgumentNullException error.

and the int.Parse will throw ArgumentNullException error.

string strCount=null;
int count1 = Convert.ToInt32(strCount);//Error
int count2 = int.Parse(strCount); // Error

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a int in c#?

885


What is c# and why it is used for?

953


Can we override main method in c#?

964


You are designing a user control. You created new property called backgroundimage which is of type image. You wanted to disable storing this property in the user’s form. How to achieve this?

919


What does assert() do in c#?

1012


If a child class instance is created, which class constructor is called first - base class or child class?

929


Can destructors have access modifiers?

960


Explain About multi level and multiple inheritance how to achieve in .net

1035


What is the diff between System.String and System.Text.StringBuilder classes?

1009


Describe the ways of cleaning up objects in c#.

909


What is a method c#?

987


Is c# scripting language?

896


What is the difference between array and arraylist in c#?

1040


What is difference between value and reference types in C#.NET

1100


List the 5 different access modifiers in c#?

927