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
What are collections in c#?
What Is A Multicast Delegate?
What is the use of tryparse in c#?
What is the difference between c and c sharp?
What is constructors, explain with syntax
What does .length do in c#?
Can you put two constructor with the same structure in a class?
How do you escape c#?
What do you know about device context?
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?
What are events in C#?
What is the namespace for the thread class?
Explain Direct CAST vs CType ?
how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used
What are the advantages of properties in c#?