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
Is double a decimal?
Can properties be private in c#?
Is string primitive?
What are the boolean data types in c#?
What is multithreading? What are the problems that comes with multithreading and how to manage them?
How does split work in c#?
What is difference between for and foreach loop in c#?
Why do we use public static void main in c#?
What is the purpose of a console table?
What is array and types of array in c#?
Is array immutable in c#?
What is the difference between malloc () and new?
Explain about CTS?
Is c# and .net same?
You have got 1 million parking slots. At a time a parking slot can be free or not. To get next slot easily which data structure to implement?