返回的值我使用的是類不能訪問通過函數
public partial class CashFlowIndicator:IEnumerable
{
public static void getCashFlowChartValues(int userid)
{
List<KeyValuePair<string, string>> chartValues=new List<KeyValuePair<string,string>>();
chartValues = cashFlowChart(userid);
}
public static List<KeyValuePair<string, string>> cashFlowChart(int userid)
{
//.............................
//..................................
List<KeyValuePair<string, string>> cashFlowItems = new List<KeyValuePair<string, string>>();
cashFlowItems.Add(new KeyValuePair<string, string>(a, b));
cashFlowItems.Add(new KeyValuePair<string, string>(c, d));
//.....................
return cashFlowItems;
}
}
的問題是在調用該函數cashFlowChart,變量「chartValues」是沒有得到返回的值分配.... 。
有沒有解決方法?
你爲什麼初始化'chartValues'給你那麼不使用反正值?你的'getCashFlowChartValues'方法在調用'cashFlowChart'後真的停止了嗎?如果是這樣,它有什麼意義呢?基本上我們需要更多的上下文 - 目前你的代碼沒有意義。 –
@JonSkeet不,我必須通過返回的值。但在此之前,我需要得到正確的值。在開發函數 – Anjana
中第一次設置'chartValues'是多餘的,因爲你正在分配一個新的值在下一行。也許有什麼事情發生在你將'cashFlowChart'編碼去掉的地方,因爲那部分代碼看起來很好。 –