基本上我有一個函數,如下,其允許用戶登錄時執行的應用程序:C#VAR基本理解
public void login(){
//Call StoredProc get a list of records
//and add the results into a list<T> SPList
var tempList = SPList.Where(x=>x.Status==1);
int counter = tempList.Count();
//What is the number of counter?
}
現在,當用戶第一次運行應用程序,login
功能將被執行並tempList.Count()
預期爲。
當用戶運行相同的方法再次login()
,所述tempList.Count()
現在變得 ??
但,如果用戶殺死的應用程序並重新啓動它,tempList.Count()
將回2再次?
是不是關鍵字VAR會刷新並每次返回2?爲什麼它保存舊數據並擴展而不是刷新?
'var'是一種紅鯡魚,我懷疑。在哪裏/如何定義SPList? –