public int GetElemList(int pos)
{
if(pos<1||pos>len)
{
Console.Write("wrong!");
}
else
{
return List[pos-1];
}
}错误是:并非所以的代码都返回值

解决方案 »

  1.   

    public int GetElemList(int pos)
    {
    if(pos<1||pos>len)
    {
    Console.Write("wrong!");
    //这里必须添加一个返回值
    return null;
    }
    else
    {
    return List[pos-1];
    }
    }
      

  2.   

    public int GetElemList(int pos)
    {
    if(pos<1||pos>len)
    {
    Console.Write("wrong!");
                                                  return 1;
    }
    else
    {
    return List[pos-1];
    }
    }
      

  3.   

    if(...)
    {
      return ...
    }
    else
    {
      return ...
    }
      

  4.   

    主要是问题太简单了,所以回复的人多,谁能帮我把这个难题搞定吗?
    http://community.csdn.net/Expert/topic/4694/4694041.xml?temp=.4028589