使用.net 1.1执行等效的int.TryParse(在.net 2.0以后找到)的最佳方法是什么.
Ant*_*lev 11
明显,
class Int32Util
{
public static bool TryParse(string value, out int result)
{
result = 0;
try
{
result = Int32.Parse(value);
return true;
}
catch(FormatException)
{
return false;
}
catch(OverflowException)
{
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3943 次 |
| 最近记录: |