Hi,

I'd like to get an entire structure to a string, without having to use a string.format for each datatype in the structure for example.


So basically I want to do something like a 'For Each value In struc'.
Is this possible?

are you looking for something like this?

Private Structure myTest
        Dim x As Integer
        Dim y As String
        Dim z As Short
    End Structure
    
        Dim xyz As New myTest With {.x = 10, .z = 12}
        Dim fields As System.Reflection.FieldInfo() = xyz.[GetType]().GetFields(System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.[Public])

        For Each field As System.Reflection.FieldInfo In fields
            Try
                MessageBox.Show(field.GetValue(xyz).ToString())
            Catch ex As NullReferenceException
                'empty y
            End Try
        Next