需要帮助Error:并非所有代码路径都返回一个值

Ser*_*ity 0 c#

我的方法是这样的: -

protected string myMethod()
    {

        if (something)
        {
            string img = "A";
            return img;
        }
        else
          if(something else)
           {
              string img = "B";
              return img;
            }

    }
Run Code Online (Sandbox Code Playgroud)

当我运行代码"并非所有代码路径都返回一个值"时显示..为什么呢?该方法返回"string img"然后为什么会出现这个错误?

Ed *_* S. 6

问你自己; 如果'别的'是假的,会发生什么?什么回来了?