Last active
August 26, 2016 18:40
-
-
Save kristoferdoman/8d48497b6fa890c89de7 to your computer and use it in GitHub Desktop.
VB.Net: Object to Dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function ToDictionary() As Dictionary(Of String, Object) | |
Dim dictionary As Dictionary(Of String, Object) = New Dictionary(Of String, Object) | |
For Each property_info As Reflection.PropertyInfo In [GetType].GetProperties() | |
Try | |
Console.WriteLine("name: " + property_info.Name + " value: " + property_info.GetValue(Me, Nothing).ToString) | |
dictionary.Add(property_info.Name, property_info.GetValue(Me, Nothing).ToString) | |
Catch ex As Exception | |
dictionary.Add(property_info.Name, ex.Message) | |
End Try | |
Next | |
Return dictionary | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment