我在我的方法中设置了一个 int 值GetDays,然后我想在里面使用这个值,GetRiskAssement()但一旦我回到这个方法,它就会更改为默认值 0。
我想设置intDays并使其保持不变,直到我GetDays再次运行该方法。
public class RiskA
{
int accountId;
static int intDays;
bool stop;
List<int> DateVehicleList = new List<int>();
public List<DisplayableRiskAssement> DisplayableRiskAssement { get; private set; }
public RiskAssement()
{
accountId = 461;
DisplayableRiskAssement = GetRiskAssement();
}
List<DisplayableRiskAssement> GetRiskAssement()
{
//Additional code here than runs through a load of records
if(riskAssement.InUK == false)
{
GetVehiclesNotInUK(riskAssement.VehicleID);
riskAssement.IntDaysSinceUK = intDays;
}
return riskAssesments;
}
protected void GetVehiclesNotInUK(int VehicleID)
{
//Code here that creates DateVehicleList
GetDays(DateVehicleList, intDays);
}
private static int GetDays(List<int> DateVehicleList, int intDays)
{
using (aEntities db = new aEntities())
{
foreach (var item in DateVehicleList)
{
var qryDate = (from a in db.ev
where a.evID == item
select a.sysdatetime).Single();
string strDate = qryDate.ToString();
DateTime oldDate = DateTime.Parse(strDate);
TimeSpan t = DateTime.Now - oldDate;
double doubleDays = t.TotalDays;
intDays = Convert.ToInt32(doubleDays);
}
}
DateVehicleList.Clear();
return intDays;
}
}
尚方宝剑之说
潇潇雨雨
九州编程
相关分类