title: Converting Structure to String
body: <p>I have defined such public structure:</p>
  
  <pre><code>Public Structure myList
      Dim a As String
      Dim b As Integer
      Dim c As Double
  End Structure
  </code></pre>
  
  <p>Later in code I assign values to it's instance:</p>
  
  <pre><code>    Dim myInstance As New myList
      myInstance.a = "Nemo"
      myInstance.b = 10
      myInstance.c = 3.14
  </code></pre>
  
  <p>And then I can convert those values to string (for storing to database) like this:</p>
  
  <pre><code>    Dim newString As String = ""
      Dim i As Integer
      Dim myType As Type = GetType(myList)
      Dim myField As System.Reflection.FieldInfo() = myType.GetFields()
      For i = 0 To myField.Length - 1
          newString &amp;= myField(i).GetValue(myInstance) &amp; " "
      Next i
  </code></pre>
  
  <p>Where string "newString" contain values of each field.
  All of that works OK.</p>
  
  <p>Now I would like to make a function for such converting for several different structures which I have in program but I can't (don't know how) to pass certain structure and instance to function.</p>
  
  <p>My try:</p>
  
  <pre><code>Public Function StructToString(ByVal myStruct As System.Type) As String
  
      Dim structString As String = ""
      Dim i As Integer
      Dim myType As Type = GetType(myStruct)
      Dim myField As FieldInfo() = myType.GetFields()
      For i = 0 To myField.Length - 1
          newString &amp;= myField(i).GetValue(Nothing) &amp; " " 
      Next i
  
      Return structString
  End Function
  </code></pre>
  
  <p>But that don't work since structure cannot be converted to type.</p>
  
  <p>Is here possibility to make such function for converting various structures to string (which can be placed to some public module) and how to do that properly?</p>