出于兴趣,可以安全地假设如果Int32.TryParse(String, Int32)失败,那么int参数将保持不变?例如,如果我希望我的整数具有默认值,哪个更明智?
int type;
if (!int.TryParse(someString, out type))
type = 0;
Run Code Online (Sandbox Code Playgroud)
要么
int type = 0;
int.TryParse(someString, out type);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |