本帖最后由 yyybbbfff 于 2010-01-14 14:41:43 编辑

解决方案 »

  1.   

    你最外面定義個變量,把return  變量 也放在最外面 for 裏 給變量賦值就行了
      

  2.   

    方法结束前, 加一句 return null;慎用!!!  请确定你的程序流程符合业务逻辑
      

  3.   

    方法结束前, 加一句 return null; 
      

  4.   


    else 
                { 
                      string URL = " <script>parent.location='LoadPage.apsx'; </script>"; 
                      return URL ; 
                    //System.Web.HttpContext.Current.Response.Write(" <script>parent.location='LoadPage.apsx'; </script>");             } 你这个句子里面没有返回值
      

  5.   


     else 
                { 
                      string URL = " <script>parent.location='LoadPage.apsx'; </script>"; 
                      return URL ; 
                    //System.Web.HttpContext.Current.Response.Write(" <script>parent.location='LoadPage.apsx'; </script>");             } 
    return ...
      

  6.   

    如果在最外面加return null的话,所有的判断都不起作用了
      

  7.   


           public string cc(int a)
            {
                if (a == 4)
                {
                    return null;
                }
                else
                {
                    string URL = " <script>parent.location='LoadPage.apsx'; </script>";
                    return URL;             }
            }
    你看我这个 和你的返回是差不多的吧 没有报错
      

  8.   

    当strTemp.Length = 0 for循环不执行的时候,程序就没有返回点了。
    建议在函数的开始处写一个返回变量,在函数的结尾返回它。
     
    string returnValue;
    .......
     for (int i = 0; i < strTemp.Length; i++) 
     { 
          // 其实if这里可以省略了
          if (strTemp[i] == UserUnit) 
          { 
                returnValue = null;  
          } 
          else 
          { 
                 string URL = " <script>parent.location='LoadPage.apsx'; </script>"; 
                 returnValue = URL ; 
           } 
     }
    return returnValue;