我想如果try到异常的话就返回false,正常的话就return true,这样的话return true和return false应该写在哪里阿?多谢!
public static bool InitForm()
{
try
   {
    ....
    }
catch
    {
    ....
    }     
return true;
}

解决方案 »

  1.   

    public static bool InitForm()
    {
    try
       {
        ....
        }
    catch
        {
        return false;
        }     
    return true;
    }
      

  2.   

    我习惯这样。
    public static bool InitForm()
    {
    bool result=true;
    try
       {
        ....
        }
    catch
        {
        result = false;
        }     
    return result;
    }
      

  3.   

    public static bool InitForm()
    {
    try{
        //....
        }
    catch
        {
        //....
        result = false;
        }     
    return true;
    }
      

  4.   

    public static bool InitForm()
    {
    try{
        //....
        return true;
        }
    catch
        {
        //....
        result = false;
        }   
    }
      

  5.   

    public static bool InitForm()
    {
    try{
        //your other code here
        return true;
        }
    catch
        {
        result = false;
        }   
    }
      

  6.   

    都行
    推荐
    public static bool InitForm()
    {
    try{
        //....
        return true;
        }
    catch
        {
        //....
        result = false;
        }   
    }