C
cwertman
Ok, Im missing something simple here.
I have an object o its a person , I want to "blank" out any properties
that are a type of a collection
The follwoing code will loop through and tell me if it is or not.
BUT I cannot figure out how to Set the Value
Dim myProperties() As PropertyInfo =
o.GetType.GetProperties((BindingFlags.Public Or BindingFlags.Instance))
Dim PropertyItem As PropertyInfo
Dim MyString As String
For Each PropertyItem In myProperties
With PropertyItem
If
GetType(ICollection).IsAssignableFrom(.PropertyType) Then
'This works to tell if its a collection
MyString = MyString & "Collection" &
..ReflectedType.ToString & " " & .PropertyType.Name & vbCrLf
'THIS IS WHAT DOES NOT WORK
PropertyItem.SetValue(o, .GetType, Nothing)
End If
End With
Next
Any Help would be super, I know its got to be just a syntax issue,
steroids, or lack of sleep
Thanks
Chris
I have an object o its a person , I want to "blank" out any properties
that are a type of a collection
The follwoing code will loop through and tell me if it is or not.
BUT I cannot figure out how to Set the Value
Dim myProperties() As PropertyInfo =
o.GetType.GetProperties((BindingFlags.Public Or BindingFlags.Instance))
Dim PropertyItem As PropertyInfo
Dim MyString As String
For Each PropertyItem In myProperties
With PropertyItem
If
GetType(ICollection).IsAssignableFrom(.PropertyType) Then
'This works to tell if its a collection
MyString = MyString & "Collection" &
..ReflectedType.ToString & " " & .PropertyType.Name & vbCrLf
'THIS IS WHAT DOES NOT WORK
PropertyItem.SetValue(o, .GetType, Nothing)
End If
End With
Next
Any Help would be super, I know its got to be just a syntax issue,
steroids, or lack of sleep
Thanks
Chris