Question: I have a precompiled struct as follow and unfortunately can not make changes in its definition

```
public struct SYSINFO          // Can not change/update this
    {
        public int ver;

        public struct printer
        {
            public string ver;
            public string serial;
            public string hserial;            
        }
        public struct laminator
        {
            public bool installed;
            public string ver;            
        }
    }

```

I am using this struct as out parameter in below code

```
uint test = smart.GetSystemInfo(out SYSINFO sinew); 
string number=sinew.printer.serial;   //<----Not working sinew doesn't have printer option

```

I need to get value of printer.serial property. I am using C# with .Net Framework 4.6.1. i can not change the struct definition.

Answer: 
For a more general solution, with my function you can easily find the first, second, third, forth or fifth sunday, monday, tuesday, wednesday or whatever you want:

```
Public Function GetXDayOfWeek(Day As DateTime,
                              DayOfWeek As DayOfWeek, 
                              Optional Index As Integer = 1) As DateTime
    Dim First As New Date(Day.Year, Day.Month, 1)
    Dim Diff As Integer = (DayOfWeek - First.DayOfWeek + 7) Mod 7

    Return First.AddDays(Diff + (Index - 1) * 7)
End Function

```

So if you want to find the forth wednesday of the current month, use it like:

```
Dim DateToFind As DateTime = GetXDayOfWeek(Today, DayOfWeek.Wednesday, 4)

```
You should make the function of getting the fourth Wednesday into a separate method, perhaps generalizing it for any day of the week, but just for the fourth Wednesday...

```
Module Module1

    Function FourthWedOfMonth(dt As DateTime) As Integer
        Dim currDate = New DateTime(dt.Year, dt.Month, 1)
        Dim nWednesdays = 0

        While nWednesdays < 4
            If currDate.DayOfWeek = DayOfWeek.Wednesday Then
                nWednesdays += 1
            End If
            currDate = currDate.AddDays(1)
        End While

        Return currDate.Day - 1

    End Function

    Sub Main()
        For mo = 1 To 12
            Console.Write(FourthWedOfMonth(New DateTime(2020, mo, 17)) & " ")
        Next

        Console.ReadLine()

    End Sub

End Module

```

Outputs the correct days for 2020:

> 
> 22 26 25 22 27 24 22 26 23 28 25 23
> 
> 
> 

If you wanted the DateTime of the fourth Wednesday, you could

```
Function FourthWedOfMonth(dt As DateTime) As DateTime
    Dim currDate = New DateTime(dt.Year, dt.Month, 1)
    Dim nWednesdays = 0

    While nWednesdays < 4
        If currDate.DayOfWeek = DayOfWeek.Wednesday Then
            nWednesdays += 1
        End If
        currDate = currDate.AddDays(1)
    End While

    Return New DateTime(dt.Year, dt.Month, currDate.Day - 1)

End Function

```

and then `Console.WriteLine(FourthWedOfMonth(DateTime.Today).ToString("dd-MMM-yyyy"))` would output "22-Jul-2020" (at the time of writing).