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

一个get{}问题,请教各位
比如三个函数,a调用b,b调用c,在c中返回值,使用get{}怎么获取c中的返回值

------解决方案--------------------
get{
a调用b;
b调用c;
return c中的返回值;
}

------解决方案--------------------
如果a和b都是当前类型的成员方法,那么可以定义一个成员变量,在b调用c的时候将c的返回值赋给这个成员变量,get中return这个成员变量即可。
如果不是,可以将a和b的返回类型定义成c的返回类型,然后依次调用,return a()
------解决方案--------------------
public void main()
{
  int all;
  int x;
  public int all
   {
     get{return all};
     set{set all=a(x);}
   }
}
private int a(int temp)
  {
    int a_temp;
    a_temp=b(temp);
    return a_temp;
  }

private int b(int temp)
{
  int b_temp;
  b_temp=c(temp);
  return b_temp;
}
private int c(int temp)
{
 return temp;
}
------解决方案--------------------

{get;set;}