private static string[] autoCompleteWordList = null; public string[] GetCompleteDepart(int count,string sql,string filed) { if (count == 0) { count = 10; } //如果數組為空 DataSet ds = new CommonDAO().ReturnDataSet(sql);//數據集 //填充數組 string[] temp = new string[ds.Tables[0].Rows.Count]; int i = 0; foreach (DataRow dr in ds.Tables[0].Rows) { temp[i] = dr[filed].ToString();//字段 i++; } //將臨時數組的內容賦給返回數組 autoCompleteWordList = temp; string[] returnValue = new string[count]; returnValue = autoCompleteWordList; //返回 return returnValue; }