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 the types of serialization?
What are the three types of predicates?
What is difference between constants and readonly in c#?
Where test director stores its data ? Database ,Local file etc...? I need to read this data from Visual Studio 2005 c# client. Regards
What is file extension of webservices?
Which .gang of four. Design pattern is shown below?
How do you escape c#?
How garbage collection deals with circular references.
What is string literal in c#?
What is a collection class in c#?
Explain About Global.asax
What is COM Interoperability?
What is connection pooling in ado.net?
What is distribute by in hive?
Define boxing and unboxing in c#?