|
|
### Int32.parse vs Convert.ToInt32(string) vs Int32.TryParse(string, out int)
|
|
|
**1. Int32.parse(string)**
|
|
|
**1. Int32.parse(string)**
|
|
|
``` cs
|
|
|
string s1 = "1234";
|
|
|
string s2 = "1234.65";
|
... | ... | @@ -14,7 +14,7 @@ |
|
|
result = Int32.Parse(s3); //-- ArgumentNullException
|
|
|
result = Int32.Parse(s4); //-- OverflowException
|
|
|
```
|
|
|
**2. Convert.ToInt32(string)**
|
|
|
**2. Convert.ToInt32(string)**
|
|
|
null reference일 때, ArgumentNullException throw하는 대신에 0을 반환한다.
|
|
|
``` cs
|
|
|
result = Convert.ToInt32(s1); //-- 1234
|
... | ... | |