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
What is xor operation?
What is Event - Delegate?
how to compare numbers and dispaly the largest ? *first thing I wanted to do is to input how many numbers to be compared *and then analyzed the largest then display it.
Is int a class in c#?
Explain About multi level and multiple inheritance how to achieve in .net
Define Abstract Class in C#
What will a loop recorder show?
Expalin the way you implement inheritance by using VB.NET/C#?
There were a lot of questions asked, so I will list the topic (and add a what is "topic" and know pros/cons). Extreme programming, what is a transaction, various SDLC design approaches, what is a namespace, define a good test case, what is a stored proc, webservice? design patterns? linker? compiler? access modifiers? stack vs. queue? arrays vs. linked lists? sorting algorithms? recursion? OOP principles?
What do u mean by thread safe?
What is a dimensional array?
Is c# code is managed or unmanaged code?
Does c# support c type macros?
What is the use of delegate?
Why is xml called extensible?