什么是针对.net 1.1的int.TryParse的最佳替代方案

Mat*_*ser 7 .net-1.1

使用.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)