c #三种四舍五入方法上取下四舍五入
Math.Round :四舍六入五取整
Math.Ceiling :向上舍入,以便有小数时加1
Math.Floor :在下面取整数,总是舍去小数
public intLongestShifttime (
{int longestShifttime=0; doublelongestshifttimeseconds=0; doublelongestshifttimesecondstemp=0;
DataSet ds=GetShiftStartEndList (; if(ds.Tables.count0) )。
//遍历开始时间列表的核对
foreach (datarowrowinds.tables [0].rows ) )。
{
datetimeshiftstarttime=datetime.parse exact (row [ ' shift start time ' ].tostring (,' HH:mm:ss ',cultureinfrinfring )
datetimeshiftendtime=datetime.parse exact (row [ ' shift end time ' ].tostring )、' HH:mm:ss '、cultureinfo.culture
timespand3=shift end time.subtract (shift start time );//判断是否需要追加一天
shiftstarttimeshiftendtime )。
{
longestshifttimesecondstemp=D3.total seconds 86400;
}else{
longestshifttimesecondstemp=D3.total seconds;
}长时间短时间码(if ) )。
{
longestshifttimeseconds=longestshifttimesecondstemp;
}
}
(if ) longestshifttimeseconds!=0)
{
longestshifttime=convert.toint 32 (math.ceiling ((longestshifttimeseconds/60 )/60 ) );
}returnlongestShifttime;
}
publicintlongestshifttime ((intlongestshifttime=0; doublelongestshifttimeseconds=0; doublelongestshifttimesecondstemp=0; DataSet ds=GetShiftStartEndList (;
if(ds.Tables.count0)//遍历开始时间列表为foreach (datarowrowinds.tables [0].rows ) datetimeshiftstarttime=datetime datetimeshiftendtime=datetime.parse exact (row [ ' shift end time ' ].tostring )、' HH:mm:ss '、cultureinfo.culture
timespand3=shift end time.subtract (shift start time );
//每天if (longestshifttimesecondstemp=D3.total seconds 86400; } else { longestshifttimesecondstemp=D3.total seconds; (if (longestshifttimesecondstemplongestshifttimeseconds ) longestshifttimeseconds=longestshifttimesecondstemp; }}if(longestshifttimeseconds!=0) longestshifttime=convert.toint 32 (math.ceiling ((longestshifttimeseconds/60 )/60 ) ); }
return longestShifttime; }