我正在尝试将此VB块转换为C#。
Public Function AddWorkingDays(ByVal DateIn As DateTime, _
ByVal ShiftDate As Integer) As DateTime
Dim b As Integer
Dim datDate As DateTime = DateIn ' Adds the [ShiftDate] number of working days to DateIn'
For b = 1 To ShiftDate
datDate = datDate.AddDays(1)
' Loop around until we get the need non-weekend day'
If Weekday(datDate) = 7 Then
datDate = datDate.AddDays(2)
End If
Next
Return datDate
End Function
到目前为止我已经
了public DateTime AddWorkingDays(DateTime DateIn, int ShiftDate)
{
int b = 0;
DateTime datDate = DateIn;
// Adds the [ShiftDate] number of working days to DateIn
for (b = 1; b <= ShiftDate; b++)
{
datDate = datDate.AddDays(1);
// Loop around until we get the need non-weekend day
if (DateAndTime.Weekday(datDate) == 7)
{
datDate = datDate.AddDays(2);
}
}
return datDate;
}
我知道C#DateAndTime中不存在我只是把它放在if语句中来完成代码块。我真正的问题是让IF语句起作用。我不确定DateTime.Now.Weekday是否与前一个VB代码中的语句相同。