日期:2014-05-17  浏览次数:20815 次

c# 方法返回值
我在写一个有返回字符串数组的方法时


public string[] ####
{
    try
    {
        if()....
        {
            return
         }
         else
         {
          .....
          return
          }
      }
      catch
      {
       }

}


其中catch 的{}内要return吗?
怎么处理啊,总报错
c# 方法

------解决方案--------------------
当初错时,你的代码没有返回值。在最后面加个return null;
------解决方案--------------------
return new string[] { };
------解决方案--------------------
catch
{
return null;
}