VB to C# conversion DateAndTime equivalent
.net, c#, vb.net
Solution
`Weekday` returns `7` for `Saturday`, so you can use `DateTime.DayOfWeek` property and compare it to `DayOfWeek.Saturday`:
if (datDate.DayOfWeek == DayOfWeek.Saturday)
{
datDate = datDate.AddDays(2);
}
Problem
I'm trying to convert this VB block to 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 ``` So far I've got ``` 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; } ``` I know that there doesn't exist in C# DateAndTime I just put it in the if statement to complete the block of code. My real problem is getting the IF statement to work. I am not sure if DateTime.Now.Weekday is the same statement as in the previous VB code.