What is the difference between int.Parse() and
Convert.toInt32().
Answer Posted / joseph
I got this example through net..hope it helps you.
Both(Convert.ToInt32 and int.Parse) will return the same
result in
most of the cases. But null is handled differently.
Consider the following example…
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 return zero.
but the int.Parse will throw ArgumentNullException error.
string strCount=null;
int count1 = Convert.ToInt32(strCount);
int count2 = int.Parse(strCount); // Error
| Is This Answer Correct ? | 50 Yes | 4 No |
Post New Answer View All Answers
Can u list some style properties of List Box?
Is string nullable c#?
Is c# different than c++?
What is a must for multitasking
How to implement delegates in c#.net
Explain the difference between boxing and unboxing.
Can a dictionary have duplicate keys c#?
HOW to Develope the CRUD(create,read,update,delete) FORM IN WINDOWS form by using c# only
Can we inherit a private class in c#?
In which format you can pass the value in the sleep function?
What is float in unity?
Show us in simple steps to create setup & deployment project for windows application?
Are structs faster than classes?
What is a collection class in c#?
What is JIT (just in time)? how it works?