Convert list to Datatable in VB.Net.
Public Function ConvertToDataTable(Of T)(ByVal list As IList(Of T)) As DataTable
Dim table As New DataTable()Dim fields() As FieldInfo = GetType(T).GetFields()
For Each field As FieldInfo In fields
table.Columns.Add(field.Name, field.FieldType)
Next
For Each item As T In list
Dim row As DataRow = table.NewRow()
For Each field As FieldInfo In fields
row(field.Name) = field.GetValue(item)
Next
table.Rows.Add(row)
Next
Return table
End Function

Abhishek AvadhootPosted Aug 30, 2019, 1:23 AM
Hi Samir, can you please help me to in vb.net to sort the ArrayList with any one of the column in that